Why it matters
Computers store most numbers in binary floating point, which can't represent 0.1 exactly. The nearest float64 is a little above 0.1, the nearest to 0.2 is a little above 0.2, and their sum rounds to a value just above the float64 nearest 0.3, so 0.1 + 0.2 === 0.3 is false. Narrower formats lose far more: float16 can't store 2049, and bfloat16, popular in machine learning, keeps only about three significant digits.
This inspector shows every bit. It rounds your number to each format with the round-half-to-even rule IEEE 754 uses, prints the exact decimal value that is stored (every finite float is an exact, if long, decimal), and measures the error. The rounding was checked against NumPy on over 800 values with no differences.
How to use it
- Type a number, a hex bit pattern such as 0x3FB999999999999A, or a sum such as 0.1 + 0.2.
- Read the bit pattern and stored value for each format.
- Check the error and any overflow or subnormal warnings.
- Enter a whole number below to see its two's complement bytes.
FAQ
Why is 0.1 + 0.2 not 0.3?
Neither 0.1 nor 0.2 is exact in binary. Their stored values add up to slightly more than the float64 nearest to 0.3, so the result is 0.30000000000000004.
What is bfloat16?
A 16-bit format with float32's 8-bit exponent but only 7 fraction bits. It has the same range as float32 with much less precision, which suits neural network training.
What is a subnormal number?
A value smaller than the smallest normal number, stored with a zero exponent so it can get closer to zero, at the cost of precision.
What is two's complement?
The usual way to store signed integers: a negative number n in w bits is stored as 2^w + n, so -1 is all ones and adding works the same for signed and unsigned values.