In this track: Digital value and units
Why Ethereum uses whole numbers
Count the smallest units, then format them for people.
A shop can store prices in cents and display them as dollars. The database avoids ambiguous fractional cents during ordinary price calculations.
1 ETH = 1000000000 Gwei = 1000000000000000000 Wei.
Store a count, not a floating label
Native ether balances are counts of Wei. A displayed 0.1 ETH corresponds to the whole number 100000000000000000 Wei. Contracts can compare and update exact integers instead of relying on decimal display strings.
A decimal convention bridges the views
The interface knows that ETH has eighteen decimal places. It places a decimal point for the user and removes it when preparing the raw amount. A token needs its own verified decimal convention; ETH’s rule cannot simply be reused for every token.
Integers still have limits
A Solidity uint256 can hold unsigned values from zero to 2²⁵⁶ − 1. Its division produces a whole-number result and discards the remainder. Exact storage of inputs does not mean every division has an exact fractional output.
Choose a consistent pipeline
Parse text into whole units, calculate with appropriately bounded integers, and format only at the edge of the interface. Our converter uses this pattern. Read rounding versus truncation before implementing division for user balances.
What should an app use for exact Wei accounting?
Keep the integer count for accounting and format a decimal representation separately.
Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.