2.2.3 RADIX NUMBER SYSTEMS
In this section, we learn how to work with numbers having arbitrary bases, although we will focus on the bases most used in digital computers, such as base 2 (binary), and its close cousins base 8 (octal), and base 16 (hexadecimal.)
The base, or radix of a number system defines the range of possible values that a digit may have. In the base 10 (decimal) number system, one of the 10 values: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 is used for each digit of a number. The most natural system for representing numbers in a computer is base 2, in which data is represented as a collection of 1’s and 0’s.
The general form for determining the decimal value of a number in a radix k fixed point number system is shown below:
The value of the digit in position i is given by bi There are n digits to the left of the radix point and there are m digits to the right of the radix point. This form of a number, in which each position has an assigned weight, is referred to as a weighted position code. Consider evaluating (541.25)10, in which the subscript 10 represents the base.
We have n = 3, m = 2, and k = 10:
5 × 102 + 4 × 101 + 1 × 100 + 2 × 10-1 + 5 × 10-2 =
(500)10 + (40)10 + (1)10 + (2/10)10 + (5/100)10 = (541.25)10
Now consider the base 2 number (1010.01)2 in which n = 4, m = 2, and k = 2:
1 × 23 + 0 × 22 + 1 × 21 + 0 × 20 + 0 × 2-1 + 1 × 2-2 =
(8)10 + (0)10 + (2)10 + (0)10 + (0/2)10 + (1/4)10 = (10.25)10
This suggests how to convert a number from an arbitrary base into a base 10 number using the polynomial method. The idea is to multiply each digit by the weight assigned to its position (powers of two in this example) and then sum up the terms to obtain the converted number. Although conversions can be made
among all of the bases in this way, some bases pose special problems, as we will see in the next section.
Note: in these weighted number systems we define the bit that carries the most weight as the most significant bit (MSB), and the bit that carries the least weight as the least significant bit (LSB). Conventionally the MSB is the left most bit and the LSB the rightmost bit.
No comments:
Post a Comment