IEEE 754 Floating-Point Converter

See how a decimal is stored as a 32-bit float or 64-bit double: sign, exponent and mantissa bits, hex, the exact stored value and the rounding error.

Use a point for decimals; E notation such as 1.5e-8 is fine. You can also type inf, -inf or nan.

Results

Bits: sign | exponent (8) | fraction (23)
0 | 01111011 | 10011001100110011001101
Hexadecimal
0x3DCCCCCD
Kind of value
Normal number: the significand has a hidden leading 1.
Sign bit
0 (positive)
Exponent field
01111011 = 123; 123 − 127 = −4
Significand (mantissa)
1.10011001100110011001101₂ = 1.60000002384185791015625
Value = sign × significand × 2^exponent
+1.600000023841857910… × 2⁻⁴
Exact value stored
0.100000001490116119384765625
Rounding error (stored − typed)
+1.490116119384765625 × 10⁻⁹

How it’s calculated

Computers store most non-whole numbers in IEEE 754 binary floating point, a binary version of scientific notation. A pattern has three fields: a sign bit (0 positive, 1 negative), a biased exponent and a fraction (mantissa). For normal numbers the significand is 1.fraction in binary, with the leading 1 not stored (the hidden bit).

normal: value = (−1)^sign × 1.fraction₂ × 2^(exponent − bias) subnormal: exponent bits all 0 → value = (−1)^sign × 0.fraction₂ × 2^(1 − bias) exponent bits all 1: fraction 0 → ±infinity; fraction ≠ 0 → not a number

Most decimals, such as 0.1, have no exact binary form, so they are rounded to the nearest pattern (ties go to the one ending in 0). The calculator shows the exact value that is stored and the rounding error. As a 32-bit float, 0.1 is stored as 0x3DCCCCCD = 0.100000001490116119384765625, an error of +1.490116119384765625 × 10⁻⁹.

Example (decoding): 0xC1B40000 is 1 | 10000011 | 01101000000000000000000. The sign is negative, the exponent field is 131 so the power is 2^(131 − 127) = 2⁴ = 16, and the significand is 1.01101₂ = 1.40625. The value is −1.40625 × 16 = −22.5.

Frequently asked questions

Why is 0.1 + 0.2 not exactly 0.3 on a computer?

None of the three numbers is exact in binary. As doubles, 0.1 and 0.2 are both stored slightly too large, and their sum rounds to 0.30000000000000004, which is a different double from the one nearest 0.3.

How many decimal digits does a float or double hold?

A 32-bit float has a 24-bit significand, about 7 significant decimal digits. A 64-bit double has 53 bits, about 15 to 17 digits. Integers are exact up to 2²⁴ = 16,777,216 in a float and 2⁵³ = 9,007,199,254,740,992 in a double.

What is a subnormal (denormal) number?

When the exponent bits are all 0, the hidden leading 1 is dropped and the power of 2 is fixed at its minimum, so numbers can shrink gradually toward zero instead of jumping straight to it. The smallest positive float is 2⁻¹⁴⁹ ≈ 1.4 × 10⁻⁴⁵.

What do infinity and NaN mean?

An exponent field of all 1s is reserved. With a zero fraction it means ±infinity, the result of overflow or 1 ÷ 0. With any other fraction it is NaN, short for “not a number”, the result of 0 ÷ 0 or the square root of a negative number.

Embed this calculator

Add this free calculator to your own website. Copy the code below into your page’s HTML:

Need this calculator branded, changed or built around your own prices?See custom business solutions →

Sources

Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.

Added · Last updated · How we check our calculators

Spotted a mistake or missing option? Report a problem· Suggest a calculator