Skip to content

IEEE 754 Floating Point Converter

Type a decimal and see the sign, exponent and fraction bits it becomes in half, single or double precision — or paste a hex or binary pattern and see the number it holds. The result includes the exact decimal value of the stored float, the rounding error against what you typed, and the floats on either side. Free, no sign-up, and everything runs in your browser.

Format
What are you entering?

Any decimal such as 0.1, -118.625 or 6.02e23, or the words Infinity and NaN. It is converted exactly and rounded to nearest, ties to even.

Result

Bit layout

Sign, exponent and fraction fields

The three fields of the pattern
FieldBitsMeaning
Sign00 means positive
Exponent01111011Stored as 123; minus the bias of 127 gives -4
Fraction10011001100110011001101Significand with the hidden bit: 1.10011001100110011001101

3DCCCCCD

Hexadecimal

Normal number

Kind

0.1

Stored value (shortest form that reads back the same)

-4

Unbiased exponent

How the value is built

(−1)⁰ × 2⁻⁴ × 1.10011001100110011001101

Rounding error

How far the stored value is from what you typed
QuantityValue
You entered0.1
Nearest binary32 value0.1
Error (stored − entered)+1.49012e−9
Relative error+1.49012e−8
Error as a fraction of one ulp0.2

An ulp is the gap between this float and the next one. Rounding to nearest never misses by more than half of it.

Exact value of the stored number

Every binary float is exactly a finite decimal. This is the whole expansion — what the bits really hold, not a rounded display.

0.100000001490116119384765625

Neighbouring floats

The floats just below and just above this one
NeighbourHexValue
Next lower3DCCCCCC0.099999994
This value3DCCCCCD0.1
Next higher3DCCCCCE0.10000001

Facts about binary32

Limits of the format
QuantityValue
Layout1 sign + 8 exponent + 23 fraction = 32 bits
Exponent bias127
Exponent range of normal numbers-126 to 127
Smallest positive subnormal1e−45
Smallest positive normal1.1754944e−38
Largest finite value3.4028235e+38
Machine epsilon (gap above 1)1.1920929e−7
Decimal digits always preserved6
Digits needed to round-trip any float9

How to Use the IEEE 754 Converter

  1. 1. Pick a format. Half (16 bits), single (32 bits) or double (64 bits). float is single in C and Java; double and JavaScript's Number are double.
  2. 2. Say what you are entering. A decimal such as 0.1, -118.625 or 6.02e23 (the words Infinity and NaN also work), or a hex or binary pattern.
  3. 3. Read the fields. The colour-coded strip and the table split the bits into sign, exponent and fraction and explain each one.
  4. 4. Check the error. For decimal input, the rounding-error table compares the stored value with what you typed, and the exact expansion shows every digit the bits really hold.

The Three Formats

IEEE 754 binary interchange formats
NameBitsExponentFractionBiasDecimal digits kept
Half (binary16)16510153
Single (binary32)328231276
Double (binary64)641152102315

A finite number is stored as (−1)s × 2e × 1.f, where s is the sign bit, f is the fraction and e is the stored exponent minus the bias. The leading 1 is not stored — it is the "hidden bit" — which is how 23 stored bits give 24 bits of precision in single precision. The bias lets the exponent field be an ordinary unsigned number while still representing negative powers.

Worked Example: −118.625 as a Single

  1. Convert to binary: the whole part, 118, is 1110110, and the fraction, 0.625, is 0.101.
  2. Normalise: move the point six places left to get 1.110110101 × 26, so the exponent is 6.
  3. Sign: the number is negative, so the sign bit is 1.
  4. Exponent field: 6 + 127 = 133 = 10000101.
  5. Fraction: the digits after the point, padded with zeros to 23 bits: 11011010100000000000000.
  6. Join them: 1 10000101 11011010100000000000000, which is C2ED4000 in hex.

This one is exact because 118.625 is a sum of powers of two (64 + 32 + 16 + 4 + 2 + 0.5 + 0.125). Most decimals are not, and the next section is what happens then.

Why 0.1 Is Never Exact

A binary float can only hold fractions whose denominator is a power of two, and 0.1 = 1/10 is not one. In single precision it becomes 3DCCCCCD, which stores exactly 0.100000001490116119384765625 — an error of about +1.49 × 10⁻⁹. In double precision it becomes 3FB999999999999A, exactly 0.1000000000000000055511151231257827021181583404541015625, an error of about +5.55 × 10⁻¹⁸. Programs print "0.1" because they print the shortest decimal that reads back as the same float, not the stored value.

The same effect explains the famous 0.1 + 0.2. Each addend is slightly off, the sum rounds again, and the double result is 3FD3333333333334 (0.30000000000000004) while the double nearest to 0.3 is 3FD3333333333333. The two differ by one unit in the last place — one ulp.

Special Values

What the exponent and fraction fields mean
Exponent fieldFractionMeaning
All zerosZero±0 — the sign bit still counts, so −0 exists
All zerosNon-zeroSubnormal: 0.f × 2min exponent, no hidden bit
1 up to all ones − 1AnythingNormal number: 1.f × 2e − bias
All onesZero±Infinity
All onesNon-zeroNaN — quiet if the top fraction bit is 1, signalling if it is 0

Subnormal numbers fill the gap between zero and the smallest normal number, trading precision for gradual underflow: the smallest subnormal is about 5.96 × 10⁻⁸ in half, 1.40 × 10⁻⁴⁵ in single and 4.94 × 10⁻³²⁴ in double. NaN carries a payload in its remaining fraction bits, which some systems use to record where a bad value came from. The converter reports both the quiet/signalling distinction and the payload.

How the Rounding Is Done

Decimal input is converted from its exact rational value with round-to-nearest, ties-to-even — the default IEEE 754 rounding. That is not the same as typing the number into JavaScript and casting down, which rounds twice (decimal to double, then double to single) and can land on the wrong neighbour when the decimal sits just above a halfway point. Overflow follows the standard too: a value at or above the largest finite number plus half an ulp becomes infinity, so 65520 is infinity in half precision while 65519.99 is 65504.

Frequently Asked Questions

How do you convert a decimal number to IEEE 754 single precision?
Write the number in binary, normalise it to 1.f × 2^e, store the sign in one bit, store e + 127 in eight bits, and store the digits of f in 23 bits, rounding to nearest if there are more. For −118.625 that gives 1 10000101 11011010100000000000000, or C2ED4000. The converter does these steps and shows every field.
Why does 0.1 + 0.2 not equal 0.3?
Neither 0.1 nor 0.2 can be stored exactly in binary, so each is rounded, and their sum is rounded again. In double precision the result is 0.30000000000000004, one ulp above the double nearest 0.3. Compare floats with a tolerance, or use decimal arithmetic for money.
What is the difference between float and double?
A float (binary32) has 24 bits of precision and about 7 significant decimal digits, with a range up to roughly 3.4 × 1038. A double (binary64) has 53 bits, about 15 to 17 digits, and a range up to roughly 1.8 × 10308. Doubles take twice the memory and are the default for floating-point numbers in most languages.
What is a subnormal (denormal) number?
A number smaller than the smallest normal float, stored with an exponent field of all zeros and no hidden leading 1. Subnormals let values shrink gradually toward zero instead of jumping to it, at the cost of fewer significant bits. They can also be slow on some processors.
What is NaN, and why is NaN not equal to itself?
NaN means "not a number" and results from operations such as 0/0 or the square root of a negative number. IEEE 754 defines every comparison involving a NaN as false except "not equal", so NaN == NaN is false. That is also the standard way to test for NaN: a value that does not equal itself.
How many decimal digits can a float hold exactly?
Any decimal with up to 6 significant digits survives a trip through single precision unchanged, and 15 digits through double precision. Going the other way, 9 digits are needed to tell every single apart and 17 to tell every double apart. The format facts table shows these figures for each format.

Related Tools

More in Data, Markup & Code

See all Data, Markup & Code