IEEE 754 Float Inspector

The bits and exact value of any float or double, such as 0.1 + 0.2.

Stored value and bits

Examples

Notable values

Questions

Why is 0.1 + 0.2 not 0.3?

Neither 0.1 nor 0.2 can be stored exactly in binary, in the same way 1/3 cannot be written exactly in decimal. Each is rounded to the nearest double. Their sum lands on the double just above 0.3, which prints as 0.30000000000000004.

What are the sign, exponent and mantissa?

The value is (-1)^sign × 1.mantissa × 2^(exponent - bias). A double has 1 sign bit, 11 exponent bits (bias 1023) and 52 mantissa bits. A float has 1, 8 (bias 127) and 23.

What is the difference between Stored and Prints?

Stored is the exact value the bits hold, every digit. Prints is the shortest decimal that rounds back to the same bits, which is what JavaScript, Python and most languages show.

Why does 16777217 change as a 32-bit float?

A float has 24 bits of precision, so above 2^24 (16,777,216) it can only store even numbers. 16,777,217 rounds to 16,777,216. A double keeps whole numbers exact up to 2^53.

What are subnormal numbers?

When the exponent bits are all zero, the leading 1 is dropped, so numbers smaller than the normal minimum can still be stored, with less precision. The smallest double, 5e-324, is one.

Can I paste raw bits?

Yes. 0x followed by 16 hex digits is read as a double, and 8 hex digits as a float. 0x3FB999999999999A is 0.1.