|
|
||
| You are here: | ||
|
4.1.3 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. a) 1.7 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. related: [ Topic 4 home | previous: binary & hexadecimal | next: more real numbers ] |
If you consider decimal numbers, when we want to represent fractions we use a decimal point: 234.56 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. |
|
|
|||
|
Questions or problems related to this web site should be addressed to Richard Jones who asserts his right to be identified as the author and owner of these materials - unless otherwise indicated. Please feel free to use the material presented here and to create links to it for non-commercial purposes; an acknowledgement of the source is required by the Creative Commons licence. Use of materials from this site is conditional upon your having read the additional terms of use on the about page and the Creative Commons Licence. View privacy policy. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. © 2001 - 2007 Richard Jones, PO BOX 246, Cambridge, New Zealand; This page was last modified: July 29, 200823, 2008 |