So far we have seen how we can express whole numbers, both positive and negative using binary but we also need to understand how we can express fractional numbers, that is, numbers that have values after the decimal point.

There are two ways that we can do this, either by using fixed point binary numbers and floating point binary numbers.

Fixed Point Binary

Imagine an ordinary, base 10 number that has some values after the decimal point, such as 123.25

We can see that the first value before the decimal point is the “beginning” of the whole number part, here there are 3 ones, then 2 tens and finally there is 1 hundred. After the decimal point we can see there are 2 tenths then there are 5 hundredths.

When we move left from the decimal point, the value of each digit increases by 10n and as we move right from the decimal point the value of each digit decreases by 10-n.

It is the same with binary, except the place value is based on 2 instead of 10.

Image showing the binary number line. There are eight bits with a decimal point in the centre. From the left of the decimal point the binary number line extends as usual. From the right of the decimal point the values are halved each time.
The binary number line for a fixed point binary number. There are 4 digits before the decimal point, the value of each digit increases by two to the power of n. There are 4 bits after the decimal point and the value of each digit decreases by two to the power of minus n.

Lets look at some examples. Say we wanted to make the value 13.5

13.5 represented as an eight bit unsigned fixed point binary number with 4 bits before the decimal point and 4 bits after the decimal point. The value 13 has been made using the 4 bits before the DP and there is a 1 under the first column after the decimal point. The place value of this column is two to the power of minus 1, otherwise known as 1/2.

As another example, 15.75 would be 1111.1100.

These examples are using unsigned binary values. We can also combine fixed point binary with twos complement. For example, to make the value -8.625

This example fixed point binary number uses 5 bits before the decimal point and 5 bits after it. The most significant bit is also the sign bit so in this example we have -8.625 because -16+8+1/2+1/8 = -8.625

There are some problems that can come about using this method, there are some decimal values that we cannot make because there are not enough digits after the decimal point. The best we can do is approximate the number we want to make and round it off. This can lead to another problem in computing called a rounding error.

The same problem occurs in decimal numbers, for example consider the value 1/3 (a third). It’s impossible to write this down as a decimal number because it would be 0.3333(the threes after the decimal point go on forever!). The effect in binary is usually more pronounced because the number of digits that a binary number can have is limited by the number of electronic circuits that the computer’s memory is made up of.

By admin