βDivision Precision Loss
What are they?
For Example in Solidity
3 / 2 = 1;
1 / 2 = 0;
Different Kind of Division Precision Loss
Division Before Multiplication
For Example
The expected result is 55.
Solidity make the first calculation 11 / 2 = 5 due to trucation
Then proceed to multiplication.
uint a = 11;
uint b = 2;
uint c = 10;
a / b * c = 50 instead of 55"Always Multiply Before Dividing"
Rounding Down To Zero
"Always make sure that the Numerator is greater than the Denominator"
Conclusion
Last updated