Fixed-point fractions
Putting a binary point at a fixed column
Fixed-point is a way to represent fractions by placing an imaginary binary point at a fixed bit position, so bits left of the point carry the usual positive powers of two and bits right of it carry negative powers (1/2, 1/4, 1/8), letting ordinary integer hardware handle fractional values.
Binary taught the whole-number weights
... 8, 4, 2, 1. To represent a fraction like 1.5, just keep going past the ones column: the next weights are 1/2, 1/4, 1/8, .... Fixed-point notation pins an imaginary binary point at an agreed column and never moves it, so the bits to its right are the fractional part. Because the point never moves, the hardware is just an ordinary integer adder; only your interpretation of where the point sits changes.Reading a fixed-point value
Suppose 8 bits in a 4.4 format: four integer bits, then the point, then four fractional bits. The weights are
8 4 2 1 . 1/2 1/4 1/8 1/16. Read a value by summing the weights of the 1 bits, exactly as in binary:0110.1000 = 4 + 2 + 1/2 = 6.5
The point is not stored anywhere; it is a convention shared by the designer and the reader. The bit pattern
01101000 is 104 read as a plain integer and 6.5 read as 4.4 fixed-point. Same bits, different agreed scale, just like the signed-versus-unsigned split.| bits (4.4) | value |
|---|---|
| 0001.0000 | 1.0 |
| 0000.1000 | 0.5 |
| 0000.0100 | 0.25 |
| 0010.1100 | 2.75 |
1/16 = 0.0625.Why it is simpler than floating point
Because the point is fixed, adding two fixed-point numbers is just an ordinary 8-bit add: the columns line up automatically. Negation still works by two's complement (invert every bit, add a
1 in the least significant position). The tradeoff is range versus resolution: with the point at a fixed column you get evenly spaced values but a limited span, whereas floating point moves the point (via an exponent) to cover a huge range at the cost of more complex hardware.Common mistakes. Both operands must use the same format before you add or compare them; adding a 4.4 value to a 6.2 value without aligning the points gives nonsense. Fixed-point cannot represent numbers whose fraction is not a sum of powers of two exactly (
0.1 decimal is a repeating binary fraction, so it rounds). And multiplying two 4.4 numbers produces an 8.8 result, so you must shift or round back to 4.4, or the point drifts.Try it
In unsigned 4.4 fixed-point, what decimal value is
0110.1000? What is the smallest nonzero value this format can represent?Answer
0110.1000: integer part 0110 = 6, fractional part .1000 = 1/2 = 0.5, so the value is 6.5. The smallest nonzero value is the lowest fractional bit, 0000.0001 = 1/16 = 0.0625, which is the format's resolution.Frequently asked
What is fixed-point representation?
Fixed-point places an imaginary binary point at a fixed bit column. Bits left of the point carry the usual positive weights (
8, 4, 2, 1) and bits right of it carry negative weights (1/2, 1/4, 1/8), so integer hardware can represent fractions. The point is a convention, not a stored bit.What is the difference between fixed-point and floating-point?
In fixed-point the binary point never moves, giving evenly spaced values but a limited range with simple integer hardware. In floating point an exponent moves the point, covering an enormous range at the cost of more complex hardware and unevenly spaced values.
How do you add fixed-point numbers?
If both numbers use the same format, you add them with an ordinary binary adder: the columns already line up because the point is fixed. Negation uses two's complement just like integers (invert the bits and add one in the lowest position).
Fixed-point is the gentle on-ramp to fractions; when a program needs both tiny and huge magnitudes, floating point moves the point automatically to cover the range.
Every lesson here builds toward one thing: a working CPU, from the transistor up.
Open the free lab →