In this track: Advanced security reasoning
Precision loss across decimals
Conversion order and rounding can destroy small values.
Changing measuring rulers repeatedly can discard fractions at every step.
1 ETH = 1000000000 Gwei = 1000000000000000000 Wei.
Track the unit of every integer
A raw amount at six decimals differs from the same displayed amount at eighteen decimals. Carry the scale through each formula explicitly.
Avoid early truncation
Dividing before multiplying can discard information that a later multiplication cannot restore. Reordering also needs overflow analysis or suitable full-precision arithmetic.
Test small and extreme values
Tiny nonzero amounts, maximum supported amounts and mixed-scale ratios reveal different problems. Include repeated conversion sequences.
Specify acceptable loss
Some rounding is unavoidable with integer units. Define who bears it and bound the allowed error under the application’s accounting rules.
Work through the boundary
floor(1 / 10) × 100 = 0
floor(1 × 100 / 10) = 10
Check overflow and intended units before choosing a real formula.A simplified local review scenario. The example establishes a question to test, not a guarantee of production safety.
Can later multiplication recover information discarded by earlier integer division?
Truncation has already removed the fractional information.
Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.