I'm having an issue where send 0.1 or 1.1 is saved as 0 and 1 in my contract's storage.

Does anyone knows how to properly pass decimals ?


1 Answer 1


Floating-point or fixed-point decimals have not yet been implemented in Solidity.

If you want, for example, 10 decimal places of precision you can just multiply all inputs by 10^10.

In this case, you would input 0.1e10 or 1.1e10 respectively, then when you fetch them you can just divide by 1e10

  • What about negative int -1 ?
    – jayD
    Commented Feb 17, 2016 at 1:34
  • negatives should still work, just use int instead of uint Commented Feb 17, 2016 at 1:35
  • Wouldn't dividing by 1e10 just chop off everything that's past the decimal anyway? Commented Jun 15, 2017 at 7:59
  • You would only do the division when displaying the value to the end user, in which case you would be using a language with floating point support like JS Commented Jun 15, 2017 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.