How a Float Is Actually Stored
IEEE 754 splits a floating point number into a sign bit, a biased exponent and a mantissa. A float32 uses 8 exponent bits and 23 mantissa bits; a float64 uses 11 and 52. The exponent is stored with a bias, 127 or 1023, so it can represent negative powers without a second sign. Values whose exponent field is all zeros are subnormal or zero, and values whose exponent field is all ones are infinity or NaN. Because the mantissa is binary, decimal fractions such as 0.1 have no exact representation, which is where familiar arithmetic surprises come from.
How to Inspect a Value
- 1Enter a decimal number, or the literals NaN, Infinity and -Infinity.
- 2Choose float32 or float64. The same decimal often rounds differently between the two.
- 3Read the coloured segments to see the sign, exponent and mantissa fields, and copy the hex or bit pattern if you need it elsewhere.
- 4Check the rounding notice: when it appears, the stored value differs from what you typed and the exact error is shown.
- 5Use the decode field to go the other way and turn a raw bit pattern back into a number.
When You Need the Bits
Explain why 0.1 + 0.2 is not 0.3
Show the stored value and the rounding error rather than describing the problem abstractly.
Debug embedded or GPU code
Compare how the same constant is stored as float32 versus float64 before it crosses an API boundary.
Investigate NaN and infinity
Confirm whether a bit pattern is a real NaN, a signed infinity or an ordinary large number.
Reason about precision limits
Use the adjacent representable values to see the actual gap between numbers at a given magnitude.
Frequently asked questions
Why does a float32 show a rounding error when float64 shows none?
The value you type is already parsed as a JavaScript double, so float64 stores it exactly by definition. Converting to float32 throws away mantissa bits, so the reported error is the real cost of narrowing to single precision.
What is a subnormal number?
When the exponent field is all zeros but the mantissa is not, the implicit leading 1 is dropped. That lets the format represent values closer to zero than a normal number allows, at the cost of precision. They are shown separately because some hardware handles them much more slowly.
Why does -0 look different from 0?
IEEE 754 has two zeros that differ only in the sign bit. They compare as equal, but they are distinguishable in the bit pattern and behave differently in some operations, such as division, where they produce opposite infinities.
What do the previous and next values tell me?
They are the closest values the format can represent on either side, so the gap between them is the resolution at that magnitude. Near 1 a double resolves about 2.2e-16, but near 1e16 the gap is larger than 1, which is why large integers stop being exact.