I know that there are no floats/doubles in Solidity but I am wondering why? I've googled it and all I can find are questions about how to deal with this lack.
I know that there are no floats/doubles in Solidity but I am wondering why? I've googled it and all I can find are questions about how to deal with this lack.
I think the reason behind is floating-point operations calculated by various functions can produce different results in different runtime environments. Ethereum blockchain is deterministic which ensures that smart contracts always produce the same output for the same input.
Also for large size of transactions, a very little difference in rounding floating numbers will cause a big difference in finance
See: https://ethereum.stackexchange.com/a/58751
The obvious reason is that floats are, by nature, unpredictable, which would make the outcome of operations different over nodes. Which would lead to forks.
Also: https://docs.soliditylang.org/en/develop/types.html#fixed-point-numbers
There are some answers that "floating points are not deterministic".
This is not true. Floating point calculations can be made deterministic with standardised software implementation.
The reason why EVM does not have floating points is
For an implementation example