IEEE 754 floating-point converter
Convert a decimal number to its 32-bit or 64-bit floating-point bits, or paste hex bits to read the number they hold.
A 32-bit float cannot hold 0.1 exactly: it stores 0.10000000149, a relative error of 1.5e-8.
What it means
Where does it sit in the float range?
Uses round-to-nearest, as every processor does by default. The binary form shows sign, exponent and fraction separated by spaces.
Every unit
That number in every format
Learn
Three things worth knowing
-
Seven and sixteen digits
Trust about 7 significant digits from a float32 and 15–16 from a float64. Integers are exact up to 16,777,216 (2²⁴) and 9,007,199,254,740,992 (2⁵³).
-
William Kahan’s standard
Before 1985 every computer rounded differently. IEEE 754, led by William Kahan, fixed the formats, the rounding and special values like infinity and NaN.
-
Comparing with ==
0.1 + 0.2 == 0.3 is false with doubles. Compare floats within a small tolerance instead.
Shortcuts
Popular number conversions
Background
About floating point
A float stores a number as sign × 1.fraction × 2exponent. A 32-bit float has 1 sign bit, 8 exponent bits and 23 fraction bits, about 7 significant digits; a 64-bit double has 11 and 52, about 16 digits.
Most decimal fractions have no exact binary form, so they are rounded: 0.1 is really 0.100000001490116… as a float and 0.1000000000000000055… as a double. That is why 0.1 + 0.2 is not exactly 0.3 in most programming languages.