Skip to content

IEEE 754 Floating-Point Converter

Convert decimals to IEEE 754 float (binary32), double (binary64) or half precision bits and back, with the exact stored value and rounding error.

Calculator Details

binary32 bits (hex):0x3DCCCCCDSee results ↓

A decimal number (0.1, -2.5e-3, 1e10, Infinity, NaN), or the bits as hex (0x3DCCCCCD) or binary

A decimal number to store, or the stored bits in hexadecimal or binary

binary32 is float (single precision), binary64 is double, binary16 is half precision

Your Results

binary32 bits (hex): 0x3DCCCCCD

binary32 bits (hex)

0x3DCCCCCD

Normal

Stored value (exact)

0.10000000149011611938476562…

29 characters; full value below

Rounding error (stored − typed)

0.00000000149011611938476562…

Relative error 1.490e-8

Shortest decimal that reads back the same

0.1

Gap to the next value (ULP)

0.000000007450580596923828125

In binary32, 0.1 is stored as 0x3DCCCCCD, exactly 0.1000000014901161193847…, off by 0.00000000149011611938….

Detailed Breakdown

The binary32 fields of 0x3DCCCCCD
FieldBitsValueMeaning
sign (1 bit)00positive
exponent (8 bits)0111 1011123123 − 127 = -4
fraction (23 bits)1001 1001 1001 1001 1001 1010x4CCCCD1 + 5033165 ÷ 2^23

All 32 bits: 0011 1101 1100 1100 1100 1100 1100 1101

Exact stored value

0.100000001490116119384765625

Error (stored − typed)

0.000000001490116119384765625

binary32: machine epsilon 0.00000011920928955078125, smallest normal 0.00000000000000000000000000000000000001…, largest finite 340282346638528859811704183484516925440.

How This Calculator Works

How it's calculated

normal: value = (−1)^sign × 2^(exponent − bias) × (1 + fraction ÷ 2^fraction bits)

subnormal (exponent field 0): value = (−1)^sign × 2^(1 − bias) × (fraction ÷ 2^fraction bits)

a decimal is rounded to the nearest value; on an exact tie, to the one with an even last bit

Your numbers: sign 0, exponent field 123 (bias 127), fraction 0x4CCCCD. The stored value is 13421773 × 2^-27 = 0.100000001490116119384765625. Your number falls between two neighbouring values 0.0000000074505805969238… apart; this is the nearer one.

Frequently Asked Questions

Why can’t 0.1 be stored exactly in binary?

In binary, 1/10 is a repeating fraction (0.000110011001100…), like 1/3 in decimal, so it has to be cut off. As a float (binary32) 0.1 is stored as 0x3DCCCCCD, exactly 0.100000001490116119384765625; as a double it is 0x3FB999999999999A, exactly 0.1000000000000000055511… (55 digits in all).

Why does 0.1 + 0.2 give 0.30000000000000004?

Both numbers are rounded when stored, and their sum is rounded again. In double precision the result is 0x3FD3333333333334, the next double above the one nearest 0.3, so printing it with the fewest digits that read back the same gives 0.30000000000000004. Compare money and other decimal quantities with a tolerance, or use decimal arithmetic.

What is the difference between float and double?

A float (IEEE 754 binary32) has 32 bits: 1 sign bit, 8 exponent bits and 23 fraction bits, about 7 significant decimal digits. A double (binary64) has 64 bits: 1, 11 and 52, about 15–17 digits and a much wider range. JavaScript numbers and Python floats are doubles; C’s float is binary32.

How is the exponent stored?

With a bias: the field holds the exponent plus 127 for binary32 (1023 for binary64, 15 for binary16), so it is never negative. An exponent field of all zeros means zero or a subnormal number; all ones means infinity or NaN.

What happens to integers above 16,777,216 in a float?

binary32 has 24 bits of precision, so above 2^24 = 16,777,216 not every integer fits: only even numbers do up to 2^25, then multiples of 4, and so on. 16,777,217 is exactly halfway between two floats and rounds to the even one, 16777216 (0x4B800000). Doubles stay exact up to 2^53.

What are subnormal numbers?

Numbers smaller than the smallest normal value, stored with an exponent field of 0 and no hidden leading 1. They fill the gap between zero and the smallest normal number, so that x − y = 0 only when x = y, but they have fewer significant bits and can be slow on some processors.

What is the “shortest decimal” the converter shows?

The decimal with the fewest significant digits that converts back to exactly the same bits. It is what most languages print by default (JavaScript’s String(x), Python’s repr). It is not the stored value: the exact value of a float usually has many more digits.

Included: IEEE 754-2019 binary16, binary32 and binary64 encoding and decoding with round to nearest, ties to even (the default rounding), subnormals, signed zero, infinities and NaN, the exact stored value and rounding error in exact decimal arithmetic, and the shortest decimal that reads back to the same bits. Left out: the other rounding directions (toward zero, up, down), decimal formats (decimal32/64/128), binary128 and x87 80-bit extended precision, bfloat16 and the 8-bit AI formats, NaN payloads and signalling NaNs (NaN text gives the default quiet NaN), and decimal input with an exponent beyond ±5,000.

IEEE 754 Converter: Float and Double Bits, Exact Values and Error

By FindMySum · Last reviewed

An IEEE 754 converter shows how a computer stores a decimal number as floating-point bits, and what value those bits really hold. Type a decimal such as 0.1 and choose a format: the converter rounds it the way the hardware does, prints the hexadecimal bits, splits them into sign, exponent and fraction, and gives the exact stored value and how far it is from what you typed. You can also paste bits in hex or binary to see the number they encode.

Three fields

Every IEEE 754 binary number is made of three fields:

FormatSign, exponent, fraction bitsPrecisionBias
binary16 (half)1, 5, 1011 bits15
binary32 (float)1, 8, 2324 bits127
binary64 (double)1, 11, 5253 bits1023

For a normal number the value is:

value = (−1)^sign × 2^(exponent field − bias) × (1 + fraction ÷ 2^fraction bits)

The leading 1 before the binary point isn't stored. Every normal number has one, so leaving it out gains a bit of precision for free; that is why a float with 23 fraction bits has 24 bits of precision.

Worked example: 0.1 as a float

The converter opens with 0.1 in binary32. In binary, one tenth is 0.0001100110011…, repeating forever. Written as 1.10011001100… × 2^-4, the exponent is −4, so the exponent field is −4 + 127 = 123 (01111011 in binary). The fraction holds the first 23 bits after the leading 1, and the 24th and later bits decide the rounding: they are more than half of the last place, so the fraction rounds up to 0x4CCCCD.

Put together, the bits are 0 01111011 10011001100110011001101, or 0x3DCCCCCD in hexadecimal. Those bits stand for exactly 0.100000001490116119384765625. The rounding error is 0.000000001490116119384765625, about 1.5 × 10^-8 of the value, and the next float up is 2^-27 (0.0000000075) away. In double precision the same 0.1 is stored as 0x3FB999999999999A, which is off by only about 5.6 × 10^-18.

Round to nearest, ties to even

A decimal usually falls between two representable values. IEEE 754's default rule picks the nearer one; if the number is exactly halfway, it picks the one whose last bit is 0 (the "even" one). Ties to even avoids the upward drift that always rounding halves up would cause over many operations.

You can see a tie with 16777217 in binary32. With 24 bits of precision, floats above 2^24 = 16,777,216 are spaced 2 apart, so 16,777,217 lies exactly halfway between 16,777,216 and 16,777,218. The even one wins: it is stored as 16,777,216, an error of −1. Integers are exact in a float only up to 2^24, and in a double up to 2^53 (9,007,199,254,740,992), which is why JavaScript calls that limit Number.MAX_SAFE_INTEGER plus one.

Special values

Two exponent field values are reserved:

  • All zeros. With a zero fraction, the value is zero; the sign bit gives +0 or −0. With a non-zero fraction it is a subnormal number: no hidden 1, and the exponent is fixed at its minimum (−126 for binary32). Subnormals let values fade gradually to zero instead of jumping from about 1.18 × 10^-38 straight to 0. The smallest positive float, 0x00000001, is 2^-149, about 1.4 × 10^-45.
  • All ones. With a zero fraction, the value is infinity; with a non-zero fraction it is NaN (not a number), the result of operations such as 0 ÷ 0.

When a decimal is too large for the format, rounding produces infinity. The largest finite binary16 value is 65,504; 65,520 sits exactly halfway between 65,504 and 2^16, ties to even rounds it up, and since 2^16 doesn't fit, the result overflows to infinity (0x7C00).

Exact value versus shortest decimal

The converter shows two decimal forms of the same bits. The exact stored value is what the bits really mean: always a finite decimal, because every binary fraction has a terminating decimal expansion, though it can run to hundreds of digits for tiny numbers. The shortest decimal is the decimal with the fewest significant digits that converts back to the same bits. That is what most programming languages print, and it is why 0.1 looks like 0.1 when you print it even though it isn't stored exactly.

When the error matters

For most measurement and science work, double precision's 15 to 17 significant digits are far more than the data carry. Errors matter when they pile up or cancel:

  • Sums of many small values collect rounding error; adding in a different order gives slightly different results. Compensated (Kahan) summation reduces it.
  • Subtracting nearly equal numbers loses the leading digits they share, leaving mostly rounding error behind.
  • Equality tests such as 0.1 + 0.2 == 0.3 fail; compare with a tolerance suited to the size of the numbers instead.
  • Money should not be stored in binary floating point at all; use integer cents or a decimal type.

Half precision deserves care of its own. With 11 bits of precision and a maximum of 65,504, it is popular for graphics and machine learning because it halves memory, but it overflows and loses precision easily, which is why training often keeps a binary32 copy of the weights.

More questions

Is IEEE 754 the same on every computer?

The formats and the basic operations (add, subtract, multiply, divide, square root) are: an IEEE 754 binary64 addition gives the same bits on any conforming system. Differences come from elsewhere: compilers reordering operations, fused multiply-add, extended-precision intermediates on old x87 code, and math library functions such as sin and exp, which the standard only recommends to be correctly rounded.

What is machine epsilon?

The gap between 1 and the next larger representable number: 2^-23 (about 1.19 × 10^-7) for binary32 and 2^-52 (about 2.22 × 10^-16) for binary64. Half of it bounds the relative rounding error of a single correctly rounded operation on normal numbers.

Why are there two zeros?

The sign bit is separate from the magnitude, so +0 and −0 both exist. They compare equal, but they behave differently in a few places: 1/+0 is +∞ and 1/−0 is −∞, and −0 records that a tiny negative result underflowed. Type -0 into the converter to see 0x80000000.

What is the difference between a quiet NaN and a signalling NaN?

Both have an exponent field of all ones and a non-zero fraction. In the 2008 and 2019 editions, the first fraction bit tells them apart: set for a quiet NaN, which passes silently through arithmetic, and clear for a signalling NaN, which raises an invalid-operation exception when used. The remaining fraction bits are a payload that some systems use for diagnostics.

Should I store money in a float or a double?

No. Amounts like $0.10 cannot be represented exactly in binary, so sums drift by fractions of a cent. Store money as an integer number of cents, or use a decimal type (SQL DECIMAL, Java BigDecimal, Python decimal, or a library such as decimal.js), and round only when displaying.

Sources

This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.

Spotted a wrong result or a bug? Report a problem

May we count your visits with Invoker Analytics? It keeps a random visitor number in your browser. Your calculator inputs are never sent. Privacy policy