OtherCalculators

IEEE 754 Floating-Point Converter

Enter a decimal to see the bits it is stored as in a 32-bit float or a 64-bit double, split into sign, exponent and mantissa, with the exact value those bits hold.

Paste a hex or binary pattern to decode it instead. Zero, −0, subnormals, Infinity and NaN are all handled, and the rounding error is printed exactly.

Last updated: · Reviewed by Shakeel Alvi, OtherCalculators

Calculator mode

Decimal to IEEE 754

Direction

Decimals, scientific notation (6.02e23), Infinity, NaN and -0 are accepted. Use a point for the decimal mark.

Format

binary32 (single precision, float): 1 sign bit, 8 exponent bits (bias 127) and 23 mantissa bits.

0.1 as 32-bit IEEE 754

3DCCCCCD

Stored value
0.100000001490116119384765625
Kind
Normal
Rounding error
0.000000001490116119384765625

Sign, exponent and mantissa

  • Sign
  • Exponent
  • Mantissa
Sign
0
positive
Exponent
01111011
123 − 127 = -4
Mantissa
1001 1001 1001 1001 1001 101
significand 1.10011001100110011001101

(−1)⁰ × 1.10011001100110011001101₂ × 2⁻⁴

The exact value stored

0.100000001490116119384765625

0.1 in binary is 0.0(0011), which repeats forever, so it is rounded to the nearest pattern that fits.

Exact at any size

Whole numbers are worked digit by digit, so 64-bit values and beyond never round off after 15 or 16 digits. Floating-point mode prints the exact value the bits store.

Runs in your browser

What you enter is worked out on this page and is not sent anywhere. Copy the address to share a conversion.

IEEE 754Float / DoubleSign · Exponent · MantissaExact Stored ValueHex Pattern

Quick answer

An IEEE 754 float stores a number as a sign bit, a biased exponent and a mantissa: 1 + 8 + 23 bits for a 32-bit float, 1 + 11 + 52 for a 64-bit double. 0.1 as a float is 0x3DCCCCCD — sign 0, exponent 123 (123 − 127 = −4) and mantissa 1.6 rounded to 23 bits — so the value actually stored is 0.100000001490116119384765625.
Guide

How the IEEE 754 converter works

Type a decimal — 0.1, −12.375 or 6.02e23 — and pick 32-bit or 64-bit. The result card shows the hex pattern, the value actually stored and how far it is from what you typed. The bit grid colours the sign, exponent and mantissa, and the field table works out the exponent minus the bias. Below that, your number is written in binary before rounding, with any repeating block in brackets, so you can see exactly why it did or did not fit.

Bits → decimal decodes a pattern copied from a debugger or a hex dump. Whole numbers stored as integers rather than floats belong in the two's complement calculator.

How the maths works

The IEEE 754 formula

Normal: value = (−1)^sign × 1.mantissa₂ × 2^(exponent − bias)
Subnormal: value = (−1)^sign × 0.mantissa₂ × 2^(1 − bias)
bias = 127 (32-bit), 1023 (64-bit)

Example: 0x40490FDB as a float: sign 0, exponent 128 − 127 = 1, mantissa 1.5707963…, so the value is 1.5707963… × 2 = 3.14159274…, the nearest float to π. The formats are defined by IEEE 754-2019 (source: IEEE).

Worked example

Worked examples

Example 1 — −12.375 as a 32-bit float

Decimal:
−12.375
  1. Sign: 1 (negative)
  2. 12.375 in binary: 1100.011
  3. Normalise: 1.100011 × 2³
  4. Exponent field: 3 + 127 = 130 = 10000010
  5. Mantissa (23 bits): 10001100000000000000000

Pattern: C1460000

12.375 = 12 + 3/8 has a power-of-2 denominator, so it is stored exactly: the rounding error is 0.

Example 2 — decoding 0x3F800000

Pattern:
0011 1111 1000 0000 …
  1. Sign bit: 0
  2. Exponent bits 01111111: 127 − 127 = 0
  3. Mantissa all zeros: 1.0

Value: 1.0 × 2⁰ = 1

Reference data

Landmark values in single and double precision

Common and boundary values with their 32-bit float and 64-bit double bit patterns in hexadecimal
Value32-bit float (hex)64-bit double (hex)
13F8000003FF0000000000000
0.53F0000003FE0000000000000
0.1 (rounded)3DCCCCCD3FB999999999999A
−2C0000000C000000000000000
−0800000008000000000000000
Smallest subnormal000000010000000000000001
Largest finite7F7FFFFF7FEFFFFFFFFFFFFF
Infinity7F8000007FF0000000000000
NaN (quiet)7FC000007FF8000000000000
Source: IEEE 754-2019 — IEEE Standard for Floating-Point Arithmetic — patterns produced by the converter's engine using the platform's IEEE 754 encoding

Key facts

  • An IEEE 754 single-precision float has 1 sign bit, 8 exponent bits with a bias of 127, and 23 mantissa bits.
  • An IEEE 754 double has 1 sign bit, 11 exponent bits with a bias of 1023, and 52 mantissa bits, and it is the format of every JavaScript number.
  • The decimal 0.1 stored as a 32-bit float is exactly 0.100000001490116119384765625, pattern 0x3DCCCCCD.
  • An exponent field of all ones means Infinity when the mantissa is zero and NaN when it is not.
When you need this

Float or double: which format are you looking at?

A C or Java float, a GPU shader value and most sensor and audio samples are 32-bit single precision, with 24 significant bits — about 7 decimal digits. A double, a Python float and every JavaScript number are 64-bit, with 53 significant bits, enough for 15 to 17 digits; MDN documents the JavaScript layout as 1 sign, 11 exponent and 52 mantissa bits (source: MDN). Use this converter when a value prints with a stray last digit, when you need to read bytes from a binary file or network packet, or when you are learning how floating point works.

Tips

Common IEEE 754 mistakes

  • Forgetting the hidden 1. A normal number's mantissa bits are the part after the point; the leading 1 is implied and not stored.
  • Reading the exponent without the bias. 01111011 is 123 stored but −4 meant.
  • Expecting decimal fractions to be exact. Only fractions whose denominator is a power of 2, such as 0.5 or 0.375, fit exactly.
  • Comparing with ==. Two routes to the “same” number can round differently; compare within a tolerance, and remember NaN never equals itself.
FAQ

Frequently Asked Questions

Why is 0.1 not stored exactly?

In binary, 0.1 is 0.000110011001100… with the 0011 block repeating forever, just as 1/3 never ends in decimal. A float has only 24 significant bits and a double 53, so the pattern is cut off and rounded. As a 32-bit float, 0.1 is really 0.100000001490116119384765625.

Why does 0.1 + 0.2 not equal 0.3 in JavaScript?

JavaScript numbers are IEEE 754 doubles. 0.1 and 0.2 are each rounded when stored, and their sum rounds to the double just above 0.3, which prints as 0.30000000000000004. Compare floating-point results with a small tolerance rather than with ===.

What is the exponent bias?

The exponent field is stored as an unsigned number with a fixed offset added, so it never needs its own sign bit. The bias is 127 for 32-bit floats and 1023 for 64-bit doubles: a stored exponent of 123 in a float means 2 to the power 123 − 127 = −4.

What is a subnormal number?

When the exponent field is all zeros, the hidden leading 1 becomes a 0 and the exponent is fixed at its minimum. That lets values smaller than the smallest normal number fade gradually to zero. The smallest positive subnormal is 2⁻¹⁴⁹ in a float and 2⁻¹⁰⁷⁴ in a double.

How are Infinity and NaN stored?

Both have an exponent field of all ones. With a mantissa of all zeros the value is Infinity, positive or negative by the sign bit; with any non-zero mantissa it is NaN. That is why 0x7F800000 is +Infinity as a float and 0x7FC00000 is a NaN.

Why are there two zeros, +0 and −0?

The sign bit is separate from the rest, so a zero can carry either sign: 0x00000000 and 0x80000000 as floats. They compare equal, but they behave differently in a few places, such as 1 / −0 giving −Infinity. The converter keeps the sign when you type -0.

Keep going

Notes & Assumptions

  • Decimals are rounded to the nearest float or double, ties to even, as IEEE 754's default rounding does. The exact stored value and the rounding error are computed with whole-number arithmetic.
  • Only the binary32 and binary64 formats are covered; half precision, extended precision and the decimal formats of IEEE 754 are not.
  • Every NaN entered as text is stored as the quiet NaN your browser produces; a pasted pattern keeps its own payload bits.

This tool is for education and debugging. Check behaviour that matters in production — rounding modes, flush-to-zero, NaN handling — against your compiler and processor documentation.