Fixed point numbers
Posted in Computing, BinaryIf we wanted to represent the number 10 in binary we may come up with something like so:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 |
But what if we wanted to represent the number 10.5? In denery we may write that as . We can do the same in binary:
| 8 | 4 | 2 | 1 | . | 1/2 | 1/4 | 1/8 | 1/16 |
|---|---|---|---|---|---|---|---|---|
| 1 | 0 | 1 | 0 | . | 1 | 0 | 0 | 0 |
We've inserted an imaginary binary point into the bit pattern and started to use binary fractions. Now suppose we wanted to represent 10.75, this can be written as
, however binary values can only take the values 1 and 0 so we can't put a 3 under the 1/4 column. We simply rewrite the fraction in terms of the fractins we do have. In this case:
So our bit pattern will look like this:
| 8 | 4 | 2 | 1 | . | 1/2 | 1/4 | 1/8 | 1/16 |
|---|---|---|---|---|---|---|---|---|
| 1 | 0 | 1 | 0 | . | 1 | 1 | 0 | 0 |
These bit patterns are called fixed point binary numbers. The advantages of using this method to represent non-integer values is that the maths involved is pretty simple and therfore easier (and quicker) to process. It is however far less acurrate for a given number of bits and allows fewer numbers to be stored.