next up previous

2.6 Data Representations     continued...

The first step in defining a representation for real numbers is to realize that binary notation can be extended to cover negative powers of two, e.g. the string ``110.101'' is interpreted as

Thus a straightforward method for representing real numbers would be to specify some location within a word as the ``binary point'' and give bits to the left of this location weights that are positive powers of two and bits to the right weights that are negative powers of two. For example, in a 16-bit word, we can dedicate the rightmost 5 bits for the fraction part and the leftmost 11 bits for the whole part. In this system, the representation of 6.625 is 0000000011010100 (note there are leading 0's to pad the whole part and trailing 0's to pad the fraction part). This representation, where there is an implied binary point at a fixed location within the word, is known as a fixed point representation.

There is an obvious tradeoff between range and precision in fixed point representations. n bits for the fraction part means there will be numbers in the system between any two successive integers. With 5 bit fractions there are 32 numbers in the system between any two integers; e.g. the numbers between 5 and 6 are 5 (5.03125), 5 (5.03125), etc. To allow more precision, i.e. smaller divisions between successive numbers, we need more bits in the fraction part. The number of bits in the whole part determines the magnitude of the largest positive number we can represent, just as it does for integers. With 11 digits in the whole part, as in the example above, the largest number we can represent in 16 bits is . Moving one bit from the whole part to the fraction part in order to increase precision cuts the range in half, and the largest number is now .