IEEE 754 Float Converter

Inputs

Like 0.1, -2.5, 6.02e23, Infinity or NaN.

Results

Bits

■ sign ■ exponent ■ mantissa (fraction)

Value actually stored
—
Difference from what you typed
—
Hex
—
Kind
—
Formula
—
Shortest decimal that reads back
—

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

  1. Type a number.
  2. Choose 64-bit double (JavaScript, Python, most languages) or 32-bit float.
  3. 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.

ParameterWhat it sets
xThe decimal number.
precision64 (double) or 32 (float).

Example: https://toolabelle.com/float-converter/#x=0.3&precision=32

Related tools