In this track: Digital value and units
Rounding versus truncation
Discarding digits and choosing the nearest display value are different operations.
A ruler can show a nearby mark or simply stop counting smaller divisions. Those two choices can disagree.
1 ETH = 1000000000 Gwei = 1000000000000000000 Wei.
Truncation drops the remainder
For non-negative integers, 7 ÷ 2 with integer division gives 3 and leaves a remainder of 1. It does not produce 3.5. If a contract divides a payment among recipients, the treatment of leftover units needs an explicit rule.
Rounding chooses a convention
A display might round 0.019 ETH to 0.02 ETH at two decimal places. Truncating to two places gives 0.01 ETH. Neither short label is the full exact amount. Never feed an abbreviated preview back into transaction accounting as though it were exact.
Direction can matter economically
Rounding a debt down and rounding a credit up can create value imbalances when repeated. Financial contract code must define the intended direction and test edge cases. A small difference repeated many times is not automatically harmless.
Prefer explicit rejection in a converter
Our converter rejects meaningful digits beyond the smallest supported unit instead of silently rounding. For ETH that means at most eighteen decimal places. Keep the exact output available even when an interface offers a shorter visual preview.
What is non-negative integer division 7 ÷ 2?
Integer division truncates the fractional part. A rounding rule must be implemented separately.
Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.