IEEE 754 Float Converter - Decimal to Binary, Hex and Exact Value

AdSense Placeholder
Slot: header_tool

IEEE 754 Float Converter

See exactly how a number is stored as a 16, 32 or 64-bit float

Click any bit to flip it. Red is the sign, green the exponent and blue the mantissa.

AdSense Placeholder
Slot: tool_mid_article

Half, Single and Double

Switch between 16, 32 and 64-bit formats and see how the same number is stored in each, and how much precision each one has.

Exact Stored Value

Shows the exact decimal value a float really holds, for example that 0.1 is stored as 0.1000000000000000055511151231257827..., and the size of the error.

Flip Bits

Click a bit to change it and watch the value, the neighbors and the special cases such as NaN, infinity and subnormals change.

Private

All conversions use exact integer arithmetic in your browser. Nothing is sent to a server.

How Floating-Point Numbers Are Stored

A binary float has three fields: a sign bit, an exponent and a mantissa (the fraction). A normal number equals (-1)^sign x 1.mantissa x 2^(exponent - bias). Only numbers that are a whole number of binary fractions can be stored exactly, so 0.5 and 0.375 are exact but 0.1 is not: it is rounded to the nearest representable value, which is why 0.1 + 0.2 does not equal 0.3 in most programming languages. The tool shows that rounding error directly.

Very small numbers lose precision gradually as subnormals, the exponent field all ones means infinity or NaN, and there are two zeros, +0 and -0. Single precision has about 7 decimal digits of precision, so 16777217 cannot be stored (the neighbors are 16777216 and 16777218). Decimal input is rounded exactly, once, from the number you typed. Rounding through double precision first, as many converters do, can give a different last bit for single precision.

Key Takeaways

  • Checked against reference libraries: Bit patterns, exact values and shortest decimals were compared with NumPy and Python on thousands of values in all three formats.
  • Ties go to even: When a value falls exactly between two floats, the one with an even last bit is chosen, as the standard requires.
  • Related tools: Use the Number Base Converter for integers and the Big Number Calculator for exact arithmetic.
AdSense Placeholder
Slot: footer_leaderboard