IEEE 754 Floating Point Converter

See how a number is stored as a 32-bit float or 64-bit double: sign, exponent and mantissa bits, hex and exact value.

Runs in your browser. Nothing is uploaded.

Number

Bit layout

How to use the IEEE 754 Floating Point Converter

  1. Type a decimal number such as 0.1, -2.5e10, Infinity or NaN, or paste a hex bit pattern.
  2. Choose 32-bit float (single) or 64-bit double under Precision.
  3. See the sign, exponent and mantissa bits highlighted in colour, and the hex pattern.
  4. Read the exact value that is actually stored and the rounding error from the number you typed.

How computers store decimal numbers

Most programming languages store fractional numbers in the IEEE 754 floating-point format. A float packs three things into a fixed number of bits: a sign bit, an exponent that sets the scale, and a mantissa (also called the significand or fraction) that holds the digits. The value is roughly sign × 1.mantissa × 2^exponent, much like scientific notation but in base 2.

This design covers a huge range, from tiny fractions to astronomically large numbers, but it can only represent values that are sums of powers of two exactly. Most decimal fractions, including 0.1, have an infinitely repeating binary expansion and must be rounded.

Seeing the rounding

Type 0.1 with 32-bit precision. The stored bits are 3DCCCCCD in hex, and the exact value of those bits is 0.100000001490116119384765625, slightly above 0.1. The tool shows that difference as the rounding error, about -1.49e-9 (what you typed minus what was stored). Switch to 64-bit and the pattern becomes 3FB999999999999A, with a much smaller error of about -5.55e-18. That error is why 0.1 + 0.2 === 0.3 is false in JavaScript, Python and most other languages.

Reading the bit layout

The bit strip colours the sign bit, exponent bits and mantissa bits differently. The exponent is stored with a bias (127 for floats, 1023 for doubles), and the tool shows the real power of two. For 0.1 it’s 2^-4, because 0.1 is between 1/16 and 1/8.

Special values

Some bit patterns have special meanings. An all-ones exponent means infinity (when the mantissa is zero) or NaN, “not a number” (otherwise). An all-zero exponent means zero or a subnormal number. Negative zero exists too, with only the sign bit set. The tool labels each case.

Going from hex to a number

Paste a hex pattern from a debugger, a binary file or network data to decode it. That’s useful for reverse engineering file formats, checking sensor data or understanding why two values that print the same aren’t equal.

All processing happens in your browser. Nothing is sent anywhere.

Frequently asked questions

Why is 0.1 + 0.2 not exactly 0.3 in JavaScript?

Neither 0.1 nor 0.2 can be stored exactly in binary, just as 1/3 can't be written exactly in decimal. Each is rounded to the nearest double, and the small errors add up to 0.30000000000000004.

What is the difference between float and double?

A 32-bit float has 1 sign bit, 8 exponent bits and 23 mantissa bits, about 7 significant decimal digits. A 64-bit double has 11 exponent and 52 mantissa bits, about 15–16 digits. JavaScript numbers are always doubles.

What are subnormal numbers?

Values so close to zero that the exponent is at its minimum. They trade precision for range, letting numbers fade gradually to zero instead of jumping straight to it.

How do I decode a float from a memory dump?

Paste the hex bytes into the hex field, 8 digits for a float or 16 for a double, in big-endian order. If your dump is little-endian, reverse the byte order first.

Is my input uploaded?

No. The conversion uses your browser's typed arrays and runs locally.

Tutorials