Floating-Point Arithmetic & Number Representation

fixed-point representation

Imagine you decide, once and for all, that money will always be written with exactly two digits after the decimal point: 3.00, 12.50, 0.07. The decimal point never moves. Fixed-point representation does exactly this inside a computer: it stores a number as a plain integer of bits, and you simply agree, in advance, where the binary point sits. The point is fixed by convention, not stored.

Concretely, a fixed-point value is just an integer N together with an implied scale: the real value is N / 2^f, where f is a chosen, constant number of fraction bits. If f = 8, then the stored integer 384 represents 384/256 = 1.5. Addition and subtraction are ordinary integer operations; multiplication produces 2f fraction bits, so you shift right by f to rescale. Because everything is integer arithmetic, fixed-point is fast, deterministic, and uses no special hardware — which is why it dominated early computing, DSP chips, and many embedded controllers.

The price is a rigid, EVENLY spaced grid. With f fraction bits the gap between neighbouring values is always 1/2^f everywhere, so you must pick a range and a precision up front and live with both: too few integer bits and large values overflow; too few fraction bits and small values lose all detail. Floating-point was invented precisely to escape this rigidity by letting the point float — trading a uniform grid for one that stretches to cover a vast dynamic range with roughly constant RELATIVE precision.

In a Q8.8 format (8 integer bits, 8 fraction bits) the bit pattern for the integer 333 means 333/256 = 1.30078125, the closest grid point to 1.3. Every value in this format is some integer over 256, and the step between neighbours is exactly 1/256 ~ 0.0039 whether you are near 0 or near 100.

Fixed-point: a uniform grid with a constant absolute step everywhere.

Fixed-point gives constant ABSOLUTE precision; floating-point gives roughly constant RELATIVE precision. Neither is 'more accurate' in general — they suit different ranges, and confusing the two is a common source of bugs.

Also called
fixed-point format定點數定點制