As shown in section 2.1, each place or position in a binary number corresponds to a specific power of 2 starting with the rightmost bit 1 which represents 20=1. It is through this organization of the bits that we will convert binary numbers to their decimal equivalent. Figure 4 shows the bit positions and the corresponding powers of two for each bit in positions 0 through 7.
power of 2
of power of 2
Figure 1.4Values Represented By Each of the First 8 Bit Positions
To begin converting an unsigned binary number to decimal, identify each bit position that contains a 1. It is important to note that we number the bit positions starting with 0 identifying the rightmost bit. Next, add the powers of 2 for each position containing a 1. This sum is the decimal equivalent of the binary value. An example of this process is shown in Figure 5 where the binary number 101101002 is converted to its decimal equivalent.
101101002 = 27 + 25 + 24 + 22
= 12810 + 3210 + 1610 + 410
Figure 1.5Sample Conversions of 101101002 to Decimal
This brings up an important issue when representing numbers with a computer. Note that when a computer stores a number, it uses a limited number of transistors. If, for example, we are limited to eight transistors, each transistor storing a single bit, then we have an upper limit to the size of the decimal value we can store.
The largest unsigned eight bit number we can store has a 1 in all eight positions, i.e., 111111112. This number cannot be incremented without forcing an overflow to the next highest bit. Therefore, the largest decimal value that 8 bits can represent in unsigned binary is the
sum of all powers of two from 0 to 7.
111111112 = 27 + 26 + 25 + 24 + 23 + 22 + 21 + 20
= 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1
If you add one to this value, the result is 256 which is 28, the power of two for the next bit position. This makes sense because if you add 1 to 111111112, then beginning with the first column, 1 is added to 1 giving us a result of 0 with a 1 carry to the next column. This propagates to the MSB where a final carry is passed to the ninth bit.
The final value is then 1000000002 = 25610.
111111112 + 1 = 1000000002 = 25610 = 28
Therefore, the maximum value that can be represented with 8 bits in unsigned binary is 28 – 1 = 255.
It turns out that the same result is found for any number of bits. The maximum value that can be represented with n bits in unsigned binary is 2n – 1.
Max unsigned binary value represented with n bits = 2n – 1 (2.1)
We can look at this another way. Each digit of a binary number can take on 2 possible values, 0 and 1. Since there are two possible values for the first digit, two possible values for the second digit, two for the third, and so on until you reach the n-th bit, then we can find the total
number of possible combinations of 1's and 0's for n-bits by multiplying 2 n-times, i.e., 2n.
How does this fit with our upper limit of 2n-1? Where does the "-1" come from? Remember that counting using unsigned binary integers begins at 0, not 1. Giving 0 one of the bit patterns takes one away from the maximum value.
For example, in the decimal system (base 10), the numeral 4327 means:
(4×103) + (3×102) + (2×101) + (7×100),
noting that 100 = 1.
In general, if b is the base, one writes a number in the numeral system of base b by expressing it in the form:
anbn + an−1bn−1 + an−2bn−2 + ... + a0b0
and writing the enumerated digits anan−1an−2...a0 in descending order. The digits are natural numbers between 0 and b − 1, inclusive. If a text (such as this one) discusses multiple bases, and if ambiguity exists, the base (itself represented in base 10) is added in subscript to the right of the number, like this: number base. Unless specified by context, numbers without subscript are considered to be decimal.
To determine the value of a binary number (1001, for example), we can expand the number using the positional weights as follows:
Here's another example to determine the value of the binary number 1101010: