Floating-Point Calculator

Convert a decimal number into its IEEE 754 binary floating-point representation and see the sign, exponent, and mantissa bits, the hex value, and how far the stored value drifts from what you typed.

Quick Facts

IEEE 754 layout
Single: 1 + 8 + 23 bits. Double: 1 + 11 + 52 bits
Sign + exponent (bias 127 / 1023) + mantissa, in that order.
Why 0.1 isn't exact
Most decimals have no finite binary fraction
Just as 1/3 repeats forever in base 10, 0.1 repeats forever in base 2 and gets rounded.

Your Results

Calculated
Binary representation
-
Sign · exponent · mantissa bits
Hexadecimal (raw bits)
-
Same bit pattern in hex
Stored value (decimal)
-
Value actually held in this format
Representation error
-
Stored value minus your input

Ready

Enter a decimal value and choose a precision format.

Understanding the Floating-Point Calculator

This tool converts a decimal number into the binary format computers actually use to store it: IEEE 754 floating-point. Nearly every modern language — JavaScript, Python, C, Java — represents non-integer numbers this way, and it explains classic surprises like 0.1 + 0.2 not quite equaling 0.3. Enter a decimal value and pick single (32-bit) or double (64-bit) precision to see the sign, exponent, and mantissa bits, the raw bits in hex, the exact decimal value that gets stored, and how far that stored value drifts from what you typed.

The IEEE 754 formula

A normal (non-zero, non-subnormal) IEEE 754 number is built from three fields and reconstructed as:

  • value = (-1)sign × 1.mantissa2 × 2(exponent − bias)
  • Sign bit: 1 bit — 0 for positive, 1 for negative.
  • Exponent: stored with a bias so it never needs its own sign. Single precision uses 8 bits with bias 127; double precision uses 11 bits with bias 1023.
  • Mantissa (significand): the fractional bits after an implied leading 1. Single precision stores 23 mantissa bits; double precision stores 52.

To encode a value, the calculator normalizes it to the form 1.xxxxx × 2e, biases the exponent, and rounds the fraction to fit the available mantissa bits — that rounding step is exactly where precision gets lost.

Single vs. double precision

  • Single precision (binary32): 1 + 8 + 23 = 32 bits total, roughly 7 significant decimal digits of precision, exponent range about 1.2×10-38 to 3.4×1038.
  • Double precision (binary64): 1 + 11 + 52 = 64 bits total, roughly 15–17 significant decimal digits, exponent range about 2.2×10-308 to 1.8×10308.

JavaScript numbers are natively double precision, so when you select the 64-bit format the "stored value" and "representation error" simply reflect what your browser already computed when it parsed your input — the error is effectively zero at that point. Switching to 32-bit shows the extra rounding that happens when a double gets squeezed into a float, which is the more visible and more common source of floating-point surprises.

Why decimals like 0.1 aren't exact

Binary floating-point can only represent a decimal exactly if it is a finite sum of powers of two (0.5, 0.25, 0.125, and combinations of them). Numbers like 0.1 or 0.3 need an infinitely repeating binary fraction, the same way 1/3 repeats forever as 0.333... in decimal. IEEE 754 rounds these to the nearest representable value, which is why 0.1 is actually stored as 0.1000000000000000055511151231257827021181583404541015625 in double precision — a number so close to 0.1 that display routines round it back to "0.1" when printed.

Frequently Asked Questions

Why doesn't 0.1 have an exact binary representation?
Binary floating-point can only represent numbers exactly when they are a sum of powers of two. 0.1 in decimal is a repeating fraction in base 2, so IEEE 754 rounds it to the nearest representable value — 0.1000000000000000055511151231257827021181583404541015625 in double precision, which prints as "0.1" because most languages show the shortest decimal that round-trips to the same stored value.
What is the difference between single and double precision?
Single precision (32-bit) uses 1 sign bit, 8 exponent bits (bias 127), and 23 mantissa bits — about 7 decimal digits of precision. Double precision (64-bit) uses 1 sign bit, 11 exponent bits (bias 1023), and 52 mantissa bits — about 15 to 17 decimal digits. JavaScript numbers are natively double precision.
How is the stored value calculated from the sign, exponent, and mantissa?
For a normal number, value = (-1)^sign × 1.mantissa (in binary) × 2^(exponent − bias). The exponent field stores exponent + bias, and the leading 1 before the mantissa is implied rather than stored. Special patterns (all-zero or all-one exponent) mark zero, subnormal numbers, infinity, or NaN instead of following this formula.