Lukas' Notes

numeric

Definition

IEEE 754

IEEE 754 is the dominant standard for floating-point number representation on computers, fixing and a family of precisions via the parameter set

Each format allocates a bit word into a one-bit sign, an exponent field of bits, and a mantissa field of bits (the leading of a normalised mantissa is implicit, so only the fractional bits are stored). The exponent is encoded with an excess (bias) , so the stored bits represent .

Formats

The two most common formats fix the parameters as follows:

Formattotal
binary32 (single)24812732
binary64 (double)5311102364

Conventions

Some bit-patterns are reserved and do not encode ordinary numbers.

Zero

Exponent bits all , mantissa all . Either sign bit yields .

Exponent bits all , mantissa with at least one bit set to .

/

Exponent bits all , mantissa all , distinguished by the sign bit.

Two further conventions handle edge cases of the normalised encoding.

Denormals

When the stored exponent is all and the mantissa is nonzero, the leading bit is taken as (not ), giving subnormal numbers that fill the gap between and the smallest normal number.

Gradual underflow

Denormals make the gap to zero shrink by a factor each step instead of collapsing from the smallest normal straight to zero, softening the loss of precision.

Examples

Converting to IEEE 754 single precision

Step 1. Convert to binary into the binary number system:

Convert

Step 2. Normalise

[!step] Step 3. Apply the excess bias
Offset exponent with excess :

Step 4. Assemble the layout

The implicit bit (, red) can be omitted since it will always be . Thus, the layout is:

The result is a 32 bit word. The most significant bit (cyan) signals that the number is negative.