IEEE 754 Float Converter

Enter a decimal number and see exactly how it is stored as an IEEE 754 32-bit float and a 64-bit double: the binary bits, the hex value, and the sign, exponent, and mantissa parts, plus the exact value the float actually holds.

Your number

Try 0.1, -2.5, 0, -0, Infinity, or NaN to see the special cases. The conversion uses your browser built-in DataView, the same float storage every computer uses.

Your result

32-bit float stores exactly—

32-bit float (single precision)

Hex—
Sign bit—
Exponent bits—
Mantissa bits—

—

64-bit double (double precision)

Hex—
Sign bit—
Exponent bits—
Mantissa bits—

—

64-bit double stores exactly—
Exponent value (32-bit)—

Enter a decimal number to see the result.

What Is an IEEE 754 Float Converter?

An IEEE 754 float converter shows how a decimal number is stored inside a computer as binary floating-point data. Computers do not store 0.1 as the digits 0 and 1; they store it as a 32-bit float or a 64-bit double, made of a sign bit, an exponent, and a mantissa, following the IEEE 754 standard that nearly every computer, phone, and programming language uses. This converter shows all three parts for both sizes, the hex value, the full binary string, and the exact value the float actually stores when it is read back.

How IEEE 754 Floats Work

A 32-bit float has 1 sign bit, 8 exponent bits, and 23 mantissa bits. The sign bit is 0 for positive numbers and 1 for negative numbers. The exponent is stored with a bias of 127, so an exponent field of 124 means a real exponent of minus 3. The mantissa stores the digits after the leading 1, which is implied and not stored. A 64-bit double works the same way with 1 sign bit, 11 exponent bits with a bias of 1023, and 52 mantissa bits, which is why it holds about 15 to 17 decimal digits instead of about 7. Special values use an exponent of all ones: a mantissa of all zeros means infinity, and any non-zero mantissa means NaN. An exponent of all zeros means zero, or a subnormal number very close to zero. Because most decimal fractions cannot be written exactly in binary, a float often stores a value very close to, but not exactly, the number you typed. That is why 0.1 plus 0.2 is not exactly 0.3 in most programming languages.

Worked Example

Example, with the default value 0.15625. As a 32-bit float it is stored as hex 0x3E200000. The binary is 0011 1110 0010 0000 0000 0000 0000 0000: the sign bit is 0, the exponent bits are 01111100, which is 124, minus the bias of 127 gives a real exponent of minus 3, and the mantissa bits are 01000000000000000000000, which is the fraction 0.25 after the leading 1. So the value is 1.25 times 2 to the power of minus 3, which is 0.15625 exactly. As a 64-bit double the same number is stored as hex 0x3FC4000000000000. A simpler case is 1, which is 0x3F800000 as a 32-bit float and 0x3FF0000000000000 as a 64-bit double. A famous rounding case is 0.1: the 32-bit float actually stores 0.10000000149011612, which is why 0.1 is never exact in floating point.

Common Mistakes

Assuming 0.1 is stored exactly. It is not. The 32-bit float nearest to 0.1 is 0.10000000149011612, and the 64-bit double nearest to it is 0.1000000000000000055511151231257827. Code that compares floats with equals instead of a small tolerance will fail on numbers like this.

Reading the exponent field as the real exponent. The stored exponent is biased: subtract 127 for a 32-bit float and 1023 for a 64-bit double. An exponent field of 124 in a 32-bit float means a real exponent of minus 3, not 124.

Forgetting the hidden leading 1. The mantissa does not include the leading 1 of the number. A mantissa of 0100... means 1.01 in binary, not 0.01, so the value is 1.25 times the power of two, not 0.25 times it.

Treating -0 and 0 as different numbers. Negative zero and positive zero compare equal in every language, but their bit patterns differ in the sign bit. Code that looks at raw bits, such as a hash function, can tell them apart.

Related Tools

Convert between units with the Unit Converter, check any percentage by hand with the Percentage Calculator, work out time zones with the Time Zone Converter, and see how dates differ with the Date Difference Calculator.

Frequently Asked Questions

Why does 0.1 plus 0.2 not equal 0.3?

Because 0.1 and 0.2 cannot be written exactly in binary, the floats nearest to them are slightly larger than the true values. Adding those two stored values gives 0.30000000000000004 in double precision, not 0.3. Compare floats with a small tolerance instead of exact equality.

What is the difference between a 32-bit float and a 64-bit double?

A 32-bit float uses 23 mantissa bits and holds about 7 decimal digits of precision, while a 64-bit double uses 52 mantissa bits and holds about 15 to 17 digits. JavaScript numbers are always 64-bit doubles, which is why this converter shows both: the 32-bit result is what a float variable in C, Java, or a GPU would store.

What does NaN mean in IEEE 754?

NaN means not a number. It is the result of an undefined operation, such as 0 divided by 0 or the square root of a negative number. It is stored with an exponent of all ones and a non-zero mantissa, and it is the only value that is not equal to itself.

What is the exponent bias?

The bias lets the exponent field store negative exponents without a sign bit. A 32-bit float adds 127 to the real exponent before storing it, and a 64-bit double adds 1023. To read the real exponent, subtract the bias from the stored field.

Why does -0 exist?

IEEE 754 keeps a sign bit even for zero, so negative zero is a distinct bit pattern. It usually comes from rounding a tiny negative number, or from dividing a negative number by infinity. It compares equal to positive zero, so it rarely matters in everyday code.