|You are here:|
see the core topic on binary numbers for this method.
In a similar way to converting decimal numbers to binary, where we used repeated division by 2, we can convert decimal fractions to binary fractions by repeated multiplication :
0.65 * 2 = 1.30 first bit is 1
0.30 * 2 = 0.60 next bit is 0
0.60 * 2 = 1.20 next bit is 1
0.20 * 2 = 0.40 0
0.40 * 2 = 0.80 0
0.80 * 2 = 1.60 1
The pattern will now repeat itself. Depending on how many bits we want to store, we truncate or round this result - let's use 5 bits:
0.101001 truncates to 0.10100 and rounds to 0.10101
The rounded version represents 1/2 + 1/8 + 1/32 = 21/32 = 0.65625 so this is not a very accurate way to store real numbers.
A number such as
1 0 1 0 1 0 . 0 1 0 1 1
is 42.34375 in decimal. We can obtain the negative two's complement representation in exactly the same was as was done for integers:
Using 8 bits for the whole number part and 5 bits for the fractional part, then 42.34375 is:
Using the above 13 bit representation , convert the following numbers to binary, truncate any bits after 5 beyond the bicimal point, if neccessary.
You can see that fixed-point representation has some limitations, just as it has in decimal. Really large and really small numbers are hard to represent unless you're prepared to allocate very many bits of storage.
If you consider decimal numbers, when we want to represent fractions we use a decimal point:
The fractional part is 5/10 + 6/100.
So, for binary it is just an extension of the column weighting system to beyond the "bicimal" point where the weights are 1/2, 1/4, 1/16 etc.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. © 2001 - 2009 Richard Jones, PO BOX 246, Cambridge, New Zealand;
This page was last modified: October 28, 2013