Skip to main content
●GuideOctober 26, 20265 min read

How to Read an IEEE 754 Float: Sign, Exponent and Mantissa

Decode any IEEE 754 float by hand: split the bits into sign, exponent and mantissa, apply the bias, and spot zeros, subnormals, infinity and NaN.

ShareXLinkedIn
How to Read an IEEE 754 Float: Sign, Exponent and Mantissa
Contents · 11 sections
  1. The three fields
  2. Decode a float by hand
  3. Special values
  4. Why 0.1 isn't exactly 0.1
  5. A debugging checklist
  6. Checking your work in code
  7. Visualizing floats with BitLens
  8. FAQ
  9. What is the exponent bias for?
  10. Is the mantissa the same as the significand?
  11. Why does my float's hex look reversed?

Short answer: an IEEE 754 float is three unsigned fields packed into one bit pattern. In single precision (32 bits), that's 1 sign bit, 8 exponent bits and 23 fraction bits. For a normal number, the value is (−1)^sign × 1.fraction × 2^(exponent − 127). So 0xC0C80000 has sign 1, exponent 129 and fraction 0.5625, which gives −1.5625 × 2² = −6.25.

Most float bugs come from reading that pattern as something else: an integer, the wrong width or the wrong byte order. Once you can split the bits yourself, those mistakes are quick to spot.

The three fields

Format Total bits Sign Exponent Fraction Exponent bias
binary32 (single, float) 32 1 8 23 127
binary64 (double, double) 64 1 11 52 1023
  • Sign: 0 is positive, 1 is negative. Flipping it negates the number, including zero, which is why −0 exists.
  • Exponent: stored with a bias so that it can be unsigned. Subtract 127 (or 1023 for binary64) to get the actual power of two.
  • Fraction (often called the mantissa): the bits after the binary point. Normal numbers have an implicit leading 1 that isn't stored, so the significand is 1.fraction.

JavaScript numbers are binary64. Most languages use binary32 for float and binary64 for double.

Decode a float by hand

Take the hex pattern C0C80000.

Diagram of the 32 bits of -6.25 (hex C0C80000): sign bit 1, exponent bits 10000001 (129, minus bias 127 gives 2), fraction bits 1001 followed by zeros (significand 1.5625), giving -1.5625 × 2² = -6.25.

-6.25 as an IEEE 754 single-precision float: one sign bit, eight exponent bits and 23 fraction bits.

  1. Expand the hex to binary, four bits per digit: 1100 0000 1100 1000 0000 0000 0000 0000. The binary, hex and octal cheat sheet covers this step.
  2. Split the bits 1 / 8 / 23: sign 1, exponent 10000001, fraction 10010000000000000000000.
  3. Sign: 1, so the number is negative.
  4. Exponent: 10000001 is 129. Subtract the bias: 129 − 127 = 2.
  5. Significand: put the implicit 1 in front of the fraction: 1.1001 in binary, which is 1 + 1/2 + 1/16 = 1.5625.
  6. Combine: −1 × 1.5625 × 2² = −6.25.

Encoding goes the other way. Write the number in binary (6.25 is 110.01), normalise it to 1.xxx × 2ⁿ (1.1001 × 2²), store n + 127 in the exponent, and store the bits after the point in the fraction.

Special values

The all-zeros and all-ones exponents are reserved:

Exponent field Fraction Meaning binary32 example
all zeros zero ±0 00000000 (+0), 80000000 (−0)
all zeros non-zero subnormal: 0.fraction × 2⁻¹²⁶ 00000001 ≈ 1.4 × 10⁻⁴⁵ (smallest positive)
1–254 any normal number 00800000 ≈ 1.18 × 10⁻³⁸ (smallest normal), 3F800000 = 1.0, 7F7FFFFF ≈ 3.40 × 10³⁸ (largest finite)
all ones zero ±infinity 7F800000 (+∞), FF800000 (−∞)
all ones non-zero NaN 7FC00000 (a common quiet NaN pattern)

Subnormals have no implicit 1, which lets values shrink gradually towards zero instead of jumping straight to it. NaN covers a whole range of patterns; in common practice the leading fraction bit marks a quiet NaN, and the remaining bits can carry a payload.

Why 0.1 isn't exactly 0.1

Many decimal fractions have no finite binary expansion, just as 1/3 has no finite decimal one. The nearest binary32 value to 0.1 is 3DCCCCCD, which is 0.100000001490116… JavaScript's Math.fround() returns that same nearest single-precision value. In binary64 the nearest value is 3FB999999999999A, which is much closer but still not exact. That's why 0.1 + 0.2 evaluates to 0.30000000000000004 in JavaScript.

The practical rule: compare floats within a tolerance suited to your values, not with ==. Number.EPSILON is the gap between 1 and the next representable binary64 number, a useful reference point. Goldberg's classic paper covers rounding error in depth.

A debugging checklist

When a float looks wrong, check these in order:

  1. Width. If it's a float at all, eight hex digits is binary32 and sixteen is binary64. Decoding one as the other gives nonsense.
  2. Byte order. On a little-endian machine, −6.25 as binary32 appears in memory as the bytes 00 00 C8 C0. Reverse the bytes before decoding a dump.
  3. Interpretation. C0C80000 read as an unsigned integer is 3,234,332,672. If you see a huge integer where you expected a small decimal, something read float bits as an integer, or the reverse.
  4. Special values. An exponent of all ones means infinity or NaN; all zeros means zero or a subnormal.
  5. Precision loss. Values that went through binary32 carry about seven significant decimal digits.

Checking your work in code

You can get the bit pattern in a line of code. In Python, struct packs a value as binary32 with the f format:

Python
import struct
struct.pack('>f', -6.25).hex()   # 'c0c80000'
struct.unpack('>f', bytes.fromhex('3dcccccd'))[0]   # 0.10000000149011612

In JavaScript, a DataView writes a float and reads the same bytes back as an integer:

JavaScript
const view = new DataView(new ArrayBuffer(4));
view.setFloat32(0, -6.25);
view.getUint32(0).toString(16);   // 'c0c80000'

Use > in Python, or the default big-endian order in DataView, so the hex reads in the same order as the diagram.

Visualizing floats with BitLens

If you decode floats often, BitLens shows the fields for you in the browser. According to its Chrome Web Store listing, its IEEE 754 float visualizer breaks down the sign, exponent and mantissa, next to multi-base conversion, bitwise operations, two's complement and ASCII/Unicode lookup. You can also highlight a number on a web page, right-click, and send it to BitLens.

It's a quick way to check a hand decode like the one above, or to inspect a value copied from a log. For binary64 values, the hand method is the same with wider fields: an 11-bit exponent with a bias of 1023 and 52 fraction bits.

FAQ

What is the exponent bias for?

It lets the exponent be stored as an unsigned number, so negative powers of two need no separate sign. For binary32 the bias is 127: a stored 127 means 2⁰.

Is the mantissa the same as the significand?

People use both words. Strictly, the stored bits are the fraction, and the significand is the fraction with the leading 1 (or 0, for subnormals) included.

Why does my float's hex look reversed?

You're probably reading memory on a little-endian machine, where the least significant byte comes first. Reverse the byte order before decoding.

To see the fields of a float in your browser, add BitLens to Chrome. It's free.

More about the extension: BitLens.

Filed underieee 754floating pointdebuggingbitlens

ShareXLinkedIn

● Related entries

  1. 01

    Two's Complement Explained: How to Write Negative Numbers in Binary

    Why 0xFF can mean 255 or -1: write negative numbers in binary with two's complement, read signed hex values, sign-extend, and catch overflow.

    GuideNovember 5, 2026
  2. 02

    Microsoft To Do Is Retiring: What Happens to Your Tasks and How to Move Them

    Microsoft To Do apps retire on 30 June 2027 and your tasks won't move to Planner automatically. What changes, what to save now, and how to pick a replacement.

    GuideNovember 22, 2026
  3. 03

    Bitcoin at C$24,250 on Kraken: What the CAD Crash Teaches About Market Orders

    Bitcoin traded at C$24,250 on Kraken's Canadian dollar pair while it sat near US$57,600 elsewhere. How a thin order book did it, and how to protect your orders.

    GuideNovember 22, 2026

Enjoyed this?
Get the next one by email.

Release notes and essays, a few times a month at most. Or follow along with the RSS feed.