# 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.

Group: Number & logic
URL: https://digiwleea.wleeaf.dev/learn/fixed-point/

[Binary](https://digiwleea.wleeaf.dev/learn/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](https://digiwleea.wleeaf.dev/learn/twos-complement/) split.

| bits (4.4) | value |
| --- | --- |
| 0001.0000 | 1.0 |
| 0000.1000 | 0.5 |
| 0000.0100 | 0.25 |
| 0010.1100 | 2.75 |

_A 4.4 fixed-point reading. The four fractional bits add halves, quarters, eighths, and sixteenths, so the smallest step (the resolution) is 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](https://digiwleea.wleeaf.dev/learn/adder8/): the columns line up automatically. Negation still works by [two's complement](https://digiwleea.wleeaf.dev/learn/twos-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](https://digiwleea.wleeaf.dev/learn/floating-point/) moves the point (via an exponent) to cover a huge range at the cost of more complex hardware.

> **WARN:** **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.

**Q (Try it):** In unsigned 4.4 fixed-point, what decimal value is `0110.1000`? What is the smallest nonzero value this format can represent?

**A:** `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.

### FAQ

**Q:** What is fixed-point representation?

**A:** 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.

**Q:** What is the difference between fixed-point and floating-point?

**A:** In fixed-point the binary point never moves, giving evenly spaced values but a limited range with simple integer hardware. In [floating point](https://digiwleea.wleeaf.dev/learn/floating-point/) an exponent moves the point, covering an enormous range at the cost of more complex hardware and unevenly spaced values.

**Q:** How do you add fixed-point numbers?

**A:** If both numbers use the same format, you add them with an ordinary binary [adder](https://digiwleea.wleeaf.dev/learn/adder8/): the columns already line up because the point is fixed. Negation uses [two's complement](https://digiwleea.wleeaf.dev/learn/twos-complement/) just like integers (invert the bits and add one in the lowest position).

> **KEY:** Fixed-point is the gentle on-ramp to fractions; when a program needs both tiny and huge magnitudes, [floating point](https://digiwleea.wleeaf.dev/learn/floating-point/) moves the point automatically to cover the range.
