IEEE 754 Float Converter
Beta: this tool hasn't been fully reviewed yet. Double-check results before relying on them.
Inputs
Like 0.1, -2.5, 6.02e23, Infinity or NaN.
Results
Enter a decimal number, Infinity or NaN.
Bits
■ sign ■ exponent ■ mantissa (fraction)
- Value actually stored
- —
- Difference from what you typed
- —
- Hex
- —
- Kind
- —
- Formula
- —
- Shortest decimal that reads back
- —
Your input is too long to share as a link, so the page address no longer includes it.
Computers store most numbers in binary floating point (IEEE 754), and most decimal fractions can’t be written exactly in binary, just as 1/3 can’t be written exactly in decimal. So 0.1 is stored as the nearest binary fraction, which is a tiny bit more than 0.1. This tool shows exactly which number is stored and how its bits are laid out.
How to use it
- Type a number.
- Choose 64-bit double (JavaScript, Python, most languages) or 32-bit float.
- Read the bits, the hex and the exact stored value.
Examples: 0.1 as a double is 0x3fb999999999999a, which is exactly 0.1000000000000000055511151231257827021181583404541015625. As a 32-bit float it’s 0x3dcccccd, exactly 0.100000001490116119384765625. 1 is 0x3ff0000000000000 and is stored exactly.
Questions and answers
Why does 0.1 + 0.2 not equal 0.3?
Both 0.1 and 0.2 are stored slightly too high, and their sum rounds to the double just above 0.3: 0.30000000000000004. 0.3 itself is stored slightly too low. Type 0.30000000000000004 and 0.3 to see both.
Which numbers are stored exactly?
Whole numbers up to 2⁵³ (about 9 quadrillion) in a double, and fractions whose denominator is a power of 2, like 0.5, 0.25 or 2.375.
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.
Link with pre-filled values
Add # and these parameters to the end of this page's address to open the tool with values already filled in.
| Parameter | What it sets |
|---|---|
x | The decimal number. |
precision | 64 (double) or 32 (float). |
Example: https://toolabelle.com/float-converter/#x=0.3&precision=32