6

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 ?

J-B
  • 8,941
  • 16
  • 46
  • 77
jayD
  • 2,462
  • 2
  • 14
  • 25

1 Answers1

6

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

Tjaden Hess
  • 37,046
  • 10
  • 91
  • 118