Boneyard Tools

IEEE 754 Floating Point Converter

Encode any decimal number into its IEEE 754 floating point bit pattern for half, single or double precision, or decode a hex or binary pattern back to its exact value. The sign, exponent and mantissa fields are broken out, with the rounding error shown.

How to convert a number to IEEE 754

  1. Pick a precision: half (16 bit), single (32 bit) or double (64 bit).
  2. Type a decimal number, or Infinity, -Infinity or NaN.
  3. Read the sign, exponent and mantissa bits, the hex and the rounding error.
  4. Switch to decode mode to turn a hex or binary pattern back into a value.

Examples

Encode 0.1 in single precision

Value 0.1, single precision
Hex 0x3DCCCCCD, not exact (stored as ~0.100000001)

Encode 1.0 in double precision

Value 1, double precision
Hex 0x3FF0000000000000, exponent 0, mantissa 0

Frequently asked questions

What is IEEE 754?

IEEE 754 is the standard that defines how computers store floating point numbers. A value is split into a sign bit, a biased exponent and a mantissa, giving half, single and double precision formats.

Why is 0.1 not stored exactly?

0.1 has no finite binary fraction, so it is rounded to the nearest value the format can hold. This tool shows the stored value and the exact rounding error, which is why 0.1 plus 0.2 is not exactly 0.3.

What is the difference between single and double precision?

Single precision uses 32 bits (8 exponent, 23 mantissa) for about 7 decimal digits. Double precision uses 64 bits (11 exponent, 52 mantissa) for about 15 to 17 digits. Half uses 16 bits for low precision storage.

How does the exponent bias work?

The stored exponent is the real exponent plus a bias: 127 for single, 1023 for double and 15 for half. So a stored exponent field of 128 in single precision means a real exponent of 1.

What are subnormal numbers and NaN?

When the exponent field is all zeros the number is zero or subnormal, filling the gap near zero. When it is all ones the value is Infinity (mantissa zero) or NaN (mantissa non-zero). The tool labels each case.

Does rounding follow a specific rule?

Yes, it uses round to nearest, ties to even, the IEEE 754 default. The encoder is computed with exact integer math so the bits match what your CPU produces.

Related tools