Skip to content

Methodology

Crypto methodology

BigInt throughout — every Wei round-trips exactly, regardless of magnitude.

The Crypto clusterconverts between three Ethereum denominations — Wei (atomic), Gwei (gas-price unit), and ETH (user-facing). The math is trivial in concept (powers of ten) and tricky in implementation (numbers exceed JavaScript’s native precision). This page explains the implementation choices.

The unit relationships

1 ETH = 10⁹ Gwei = 10¹⁸ Wei

The EVM stores all balances and arithmetic in Wei as unsigned 256-bit integers. ETH and Gwei are purely human-facing labels with no on-chain representation — they’re division-by-power-of-ten conventions for display.

Why BigInt is mandatory

JavaScript’s Number type uses IEEE 754 double precision: ~15-17 significant decimal digits. Number.MAX_SAFE_INTEGER is 2⁵³ − 1 ≈ 9.007 × 10¹⁵. A 9 ETH balance is roughly 9 × 10¹⁸ Wei — three orders of magnitude past the precision floor.

Concretely: if you store 1.234567890123456789 ETH in a Number and convert to Wei, the last several digits get rounded. If you accept that string as input from a wallet and pass it to a smart contract, the contract receives a different number than the user thought they sent.

Production crypto libraries (ethers.js, viem, web3.js) all use BigInt or a BigNumber wrapper for Wei amounts. Our converter uses native BigInt throughout. Inputs accept decimal strings; the conversion parses them carefully to avoid premature Number coercion.

The decimal-string parsing path

For a user input like 1.234 ETH:

  1. Split on the decimal point. Integer part: 1; fractional part: 234.
  2. Pad the fractional part to 18 digits (ETH’s precision): 234000000000000000.
  3. Concatenate: 1234000000000000000.
  4. Construct a BigInt from the result.
  5. To convert to Gwei, divide by 10⁹ (BigInt division is integer division — this is correct because Gwei has 9 fewer decimal places than Wei).

Conversions to ETH for display reverse the process: divide the BigInt by 10¹⁸ to get the integer part, modulo 10¹⁸ for the fractional part, format as a decimal string with leading zeros where needed. Trailing zeros are stripped for readability.

Round-trip guarantee

Any conversion through our calculator round-trips exactly. Specifically:

  • ETH → Wei → ETH preserves all 18 fractional digits.
  • Gwei → Wei → Gwei preserves all 9 fractional digits.
  • Wei → ETH → Wei is exact because Wei amounts are integers.

Inputs with more precision than the unit supports (e.g., “1.5 Wei”) get truncated, not rounded — sub-Wei amounts don’t exist.

What we don’t do

  • Live ETH price. Coming in Wave 2 (CoinGecko API + ISR cache).
  • Other chains. Most EVM-compatible chains use the same Wei/Gwei/native-token hierarchy — replace the “ETH” label with MATIC, BNB, ARB, etc., and the math is identical.
  • Bitcoin denominations. 1 BTC = 100,000,000 satoshi fits in a 64-bit integer comfortably; BigInt isn’t needed. Our underlying library supports BTC ↔ satoshi conversion; the UI tool ships in a later batch.
  • Transactions. We don’t submit anything to any network.

Related

Published May 14, 2026