August 2019
Intermediate to advanced
486 pages
13h 52m
English
In the Solidity language, there is no official support for floating-point numbers. In the future, there will be support for floating-point numbers. Developers have to use unsigned uintX or signed intX integers only for their calculations. Hence, if any division operation is performed, the result of that calculation might have rounding errors. The result is always rounded down to the nearest integer.
Here is an example in the following code:
//Bad Practiceuint result = 5 / 2;
The preceding code would set value 2 in the result variable, as 2.5 rounded down to the nearest integer.
These rounding errors could cause problems when you are calculating some values that affect tokens, bonuses, or dividends. Hence, a developer ...