IEEE 754 Float Inspector
The bits and exact value of any float or double, such as 0.1 + 0.2.
Notable values
- 0.1 in floating point
- Why 0.1 + 0.2 is not 0.3
- Number.MAX_SAFE_INTEGER (2^53 - 1)
- 2^53 + 1 cannot be stored
- Number.EPSILON (machine epsilon)
- Number.MAX_VALUE, the largest double
- Number.MIN_VALUE, the smallest double
- Negative zero (-0) in floating point
- NaN (not a number) in floating point
- Infinity in floating point
- 16777217, the first integer a float cannot store
- 1/3 in floating point
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.
Related tools
- Base ConverterBinary, octal, decimal and hex, all at once.
- Data Size ConverterBytes, KB/MB/GB and KiB/MiB/GiB, all at once.
- Chmod CalculatorUnix permissions as octal (755) and letters (rwxr-xr-x), with what each one allows.
- Token CounterCount tokens and see how text is split, with the real GPT-4o and GPT-4 tokenizers.