| | | | | linguist.page@gmail.com

How does a machine store 3.14? Integers are straightforward — but fractions have infinite precision, and memory is finite. Something has to give.

The solution: don’t store the number exactly. Store its shape.


Scientific Notation First

In decimal: 3.143.14 × 10⁰ — or moved: 0.314 × 10¹

The same idea works in binary. Any number can be written as:

1.something × 2^exponent

The 1. before the point is always there in binary — so we don’t store it. That free bit buys us extra precision.


The 32-bit Structure

IEEE 754 single precision splits 32 bits into three fields:

| 1 bit  | 8 bits   | 23 bits    |
| Sign   | Exponent | Mantissa   |

Example: −6.5

6.5 = 110.1 in binary
    = 1.101 × 2²

Sign     → 1
Exponent → 2 + 127 = 129 → 10000001
Mantissa → 101 followed by 20 zeros

Result: 1 10000001 10100000000000000000000

The Trade-off

Floating point is an approximation. 0.1 in binary is a repeating fraction — like 1/3 in decimal. It never terminates.

This is why 0.1 + 0.2 in most programming languages gives:

0.30000000000000004

Not a bug. A consequence of finite bits representing infinite precision.


The Pattern

Sign → Exponent → Mantissa

value = (-1)^sign × 1.mantissa × 2^(exponent - 127)

IEEE 754 doesn’t store numbers — it stores instructions for reconstructing them. Precision is traded for range. Exactness is traded for universality. Every decimal you type is an approximation the machine agreed to keep.