Re:Understanding Ethereum Smart Contracts
by jatsign on Wednesday November 29, 2017 @08:45AM
(#15806656)
And it's exasperated by the fact that most Tokens use 18 decimal places of precision. So "1" would be 1000000000000000000. As a programmer, I just found it harder to reason about numbers like that.
I ran into problems testing my solidity contract with javascript, because javascript isn't great at big numbers. Or division.
Re:Understanding Ethereum Smart Contracts
by workmandan on Wednesday November 29, 2017 @08:41AM
(#15806622)
Dang you got there 3 minutes before me!
About the point on using floats, one should never use floats when working with money, this is because floats are not precise and result in rounding errors (eg. 0.1 + 0.2 results 0.30000000000000004, see for details http://0.30000000000000004.com ). One of the simplest approaches to solve it is to work with the smallest units, so if working with dollars then you can use cents and that means you can use integers which give more precision, which is how Solidity currently deals with it, by working with the smallest unit of Ether which is 'wei'. Some of the units listed here https://etherconverter.online