In this track: Digital value and units
beginner · 3 MIN READ

Why Ethereum uses whole numbers

Count the smallest units, then format them for people.

LET’S PICTURE IT

A shop can store prices in cents and display them as dollars. The database avoids ambiguous fractional cents during ordinary price calculations.

SEE IT FOR YOURSELF
The same native ether amount shown as ETH, Gwei and WeiETH1× 1 billionGWEI1000000000× 1 billionWEI1000000000000000000

1 ETH = 1000000000 Gwei = 1000000000000000000 Wei.

Same value · different units · native ether only

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.

TURN UNDERSTANDING INTO PRACTICEOpen the Wei / Gwei / ETH →
QUICK CHECK · NO PRESSURE

What should an app use for exact Wei accounting?

Your progress stays in this browser.
Keep exploring the original referenceethereum.org ↗

Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.