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 ?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityI'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 ?
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