Toolstia / IEEE 754 floating point converter

IEEE 754 floating point converter

Enter a decimal number, hex or binary bits and see how a computer stores it as a 32 bit or 64 bit floating point value. The tool splits the bits into sign, exponent and fraction and shows the exact value that is really stored.

Red is the sign bit, blue the exponent and green the fraction. Most decimal fractions such as 0.1 cannot be stored exactly in binary, so the stored value is the nearest one that can.

How it works

  1. Choose single or double precision.
  2. Enter a decimal number, or hex or binary bits.
  3. Read the bit fields, the hex form and the exact stored value.

The three parts

A float has one sign bit, an exponent field (8 bits for single, 11 for double) and a fraction field (23 or 52 bits). Normal numbers have an implied leading 1.

Why 0.1 is not exact

Many decimal fractions have no finite binary form, so the nearest float is stored instead. The tool shows that value to every digit, such as 0.1000000000000000055511151231257827 for the double 0.1.

Special values

An exponent field of all ones means infinity or NaN. An exponent field of zero means zero or a subnormal number, which fills the gap near zero.

Hex and binary input

Paste exactly 8 hex digits (32 bit) or 16 (64 bit), or the full number of binary digits, to decode a stored float.

Questions

Why does 0.1 + 0.2 not equal 0.3?

Both 0.1 and 0.2 are stored with a tiny error, and the errors add up in the sum. Everything happens in your browser, and nothing you enter is sent anywhere.

Is the 32 bit value rounded?

Yes. A single precision float has about 7 decimal digits of precision, so the tool rounds your number to the nearest one.

What is a subnormal number?

A number so close to zero that it loses the implied leading 1 and gives up precision to reach even smaller values.