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.

-6.25 as an IEEE 754 single-precision float: one sign bit, eight exponent bits and 23 fraction bits.
- 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. - Split the bits 1 / 8 / 23: sign
1, exponent10000001, fraction10010000000000000000000. - Sign: 1, so the number is negative.
- Exponent:
10000001is 129. Subtract the bias: 129 − 127 = 2. - Significand: put the implicit 1 in front of the fraction:
1.1001in binary, which is 1 + 1/2 + 1/16 = 1.5625. - 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:
- Width. If it's a float at all, eight hex digits is binary32 and sixteen is binary64. Decoding one as the other gives nonsense.
- 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. - Interpretation.
C0C80000read 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. - Special values. An exponent of all ones means infinity or NaN; all zeros means zero or a subnormal.
- 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:
import struct
struct.pack('>f', -6.25).hex() # 'c0c80000'
struct.unpack('>f', bytes.fromhex('3dcccccd'))[0] # 0.10000000149011612In JavaScript, a DataView writes a float and reads the same bytes back as an integer:
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.
