Skip to content

Latest commit

 

History

History
11 lines (8 loc) · 740 Bytes

File metadata and controls

11 lines (8 loc) · 740 Bytes

Precision Loss in Calculations

Description:

Smart contracts are high-level programs that are translated into EVM byte code and then deployed to the Ethereum blockchain for execution. Solidity mathematic procedures are similar to other programming languages. The following arithmetic operations are applicable to Solidity: Addition, Subtraction, Multiplication, Division (x / y), Modulus (x% y), Exponential (x**y) In the case of performing Integer division, Solidity may truncate the result. Hence we must multiply before dividing to prevent such loss in precision

Remediation:

Multiply before divide to avoid loss of precision

References:

https://blog.solidityscan.com/precision-loss-in-arithmetic-operations-8729aea20be9