Dev · Converter

IEEE 754 float converter: decimal to binary and hex.

Enter a decimal such as 0.1, or a hex or bit pattern, and see the float32 or float64 sign, exponent and fraction bits, the bias, whether it is normal, subnormal, zero, infinity or NaN, and the exact decimal value actually stored. Everything runs in your browser; nothing is sent.

float32: 1 + 8 + 23 bits, bias 127 float64: 1 + 11 + 52 bits, bias 1023

Advertisement

Inputs

A decimal (0.1, -1.5e-3), nan, inf, -inf, 0x hex (8 or 16 digits) or 0b bits (32 or 64).

Result

Enter a value and press Convert.

How an IEEE 754 float is laid out

A binary float is a sign bit, a biased exponent field and a fraction (mantissa) field. float32 uses 1, 8 and 23 bits with bias 127; float64 uses 1, 11 and 52 bits with bias 1023 (IEEE 754-2019). For a normal number the value is (−1)sign × 1.fraction × 2(exponent field − bias). The leading 1 is implied and not stored.

Subnormals, zero, infinity and NaN

An exponent field of all zeros means subnormal (or zero when the fraction is also zero): there is no implied leading 1 and the exponent is fixed at 1 − bias, which lets values shrink gradually towards zero. An exponent field of all ones means infinity when the fraction is zero, otherwise NaN. Under IEEE 754-2019 the top fraction bit distinguishes a quiet NaN (1) from a signaling NaN (0). Zero has a sign, so −0 and +0 are different bit patterns. Worked example from Wikipedia: 0.15625 in float32 is 0x3E200000, with exponent field 124 (124 − 127 = −3).

Why 0.1 + 0.2 is not 0.3

0.1 has no finite binary expansion, so a float64 stores the nearest representable value instead. JavaScript’s Number is float64, and this page reads the bits with DataView and expands them exactly with BigInt. Computed live in your browser:

The sum of the two stored values lands on a different neighbouring float than the one 0.3 rounds to, so the comparison is false. Related: to see signed integers as bit patterns, use the binary converter.

What this does and doesn’t

This shows the bits your browser’s float32/float64 rounding produces (round to nearest, ties to even) and the exact value they represent. It does not cover decimal or half/quad formats. NaN payloads and sign are shown from the bits you give; a NaN typed as text is the browser’s canonical quiet NaN.

Advertisement
Advertisement
Listening…