Google
 
Site navigation: [ Home | Theory | Java | About ]

Fixed point representation

4.1.3
Both fixed and floating point (next) representations are required.

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:

-128

64

32

16

8

4

2

1

.

1/2

1/4

1/8

1/16

1/32

0

0

1

0

1

0

1

0

.

0

1

0

1

1

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
b) the largest possible negative number
c) the smallest possible positive number

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.

Back to top

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.


 
The site is partly financed by advertising revenue, partly by online teaching activities and partly by donations. If you or your organisation feel these resouces have been useful to you, please consider a donation, $9.95 is suggested. Please report any issues with the site, such as broken links, via the feedback page, thanks.

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.

Creative Commons License


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