3.4: Binary and decimal numbers
Decimal | Binary |
---|---|
0 | 0 |
1 | 1 |
2 | 10 |
3 | 11 |
4 | 100 |
5 | 101 |
6 | 110 |
7 | 111 |
8 | 1000 |
9 | 1001 |
10 | 1010 |
Figure 3.1: A 2-byte word
3.4 Octal Number System
The octal number system uses the number 8 as its base. It has eight unique counting symbols (0, 1, 2, 3, 4, 5, 6, and 7). Table 3.5 shows octal numbering with their decimal and binary equivalents.
Each digit in an octal number has a place value that is a power of eight raised to n (or 8n), where n is the position, as shown in Table 3.6.
The octal number 25738 is equivalent to the decimal number 1403 (or 1024 + 320 + 56 + 3). Its conversion is shown below.
We can express 25738 = 140310.
The octal numbering system uses one digit to represent three binary digits (or bits). In this way, a large binary number can be readily represented by an octal number with much fewer digits (Figure 3.2). As can be seen, that one 15-bit binary number is expressed by a 5-digit octal number.
Table 3.5: Octal numbering with decimal and binary equivalents
Octal | Decimal | Binary |
---|---|---|
0 | 0 | 0 |
1 | 1 | 1 |
2 | 2 | 10 |
3 | 3 | 11 |
4 | 4 | 100 |
5 | 5 | 101 |
6 | 6 | 110 |
7 | 7 | 111 |
10 | 8 | 1000 |
11 | 9 | 1001 |
12 | 10 | 1010 |
13 | 11 | 1011 |
14 | 12 | 1100 |
15 | 13 | 1101 |
16 | 14 | 1110 |
17 | 15 | 1111 |
3.5 Hexadecimal Number System
The hexadecimal number system uses the number 16 as its base. It has sixteen unique counting symbols, the numerals 0 – 9 and the letters A – F. Table 3.7 shows hexadecimal numbering with their decimal and binary equivalents.
Each digit in a hexadecimal number has a place value 16n that is a power of sixteen raised to n, where n is the position as shown in Table 3.8.
Table 3.6: Place values of octal numbers
Figure 3.2: An octal number
The hexadecimal number 23B16 is equivalent to the decimal number 57110 (or 512 + 48 + 11). Its conversion is shown below:
The decimal equivalent of 23B16 = 57110.
The hexadecimal numbering system uses one digit to represent four binary digits (or bits). In this way, a very large binary number can be concisely represented by a hexadecimal number with very few digits (Figure 3.3). In this example, one 16-bit binary number is expressed by a 4-digit hexadecimal number.
Table 3.7:: Hexadecimal numbering with decimal and binary equivalents
Hexadecimal | Decimal | Binary |
---|---|---|
0 | 0 | 0 |
1 | 1 | 1 |
2 | 2 | 10 |
3 | 3 | 11 |
4 | 4 | 100 |
5 | 5 | 101 |
6 | 6 | 110 |
7 | 7 | 111 |
8 | 8 | 1000 |
9 | 9 | 1001 |
A | 10 | 1010 |
B | 11 | 1011 |
C | 12 | 1100 |
D | 13 | 1101 |
E | 14 | 1110 |
F | 15 | 1111 |
3.6 Number Conversions
The same numerical quantity can be expressed in different numbering systems and their expressions are equivalent to each other. To facilitate the number conversions in various numbering systems, numbers need to be expressed with their numbering base. A numerical quantity of 12 is expressed in four number systems as follows:
1210 = 148 = C16 = 11002
Table 3.8: Place values of hexadecimal numbers
Figure 3.3: A hexadecimal number
The focus of this section is to show the techniques of converting a numerical quantity from one number system to another. A decimal number can be converted to binary, octal, and hexadecimal. Converting a decimal number to its equivalent in another number system involves the process of dividing the decimal number by the base number of the system from which the conversion is made. The conversion to binary involves division by 2, conversion to octal involves division by 8, and conversion to hexadecimal involves division by 16. The generic procedure involves:
a.Dividing the decimal number by the base number.
Decimal number ÷ Base number = Quotient (Q1) + Remainder (R1)
Quotient (Q1) ÷ Base number = Quotient (Q2) + Remainder (R2)
Quotient (Q2) ÷ Base number = Quotient (Q3) + Remainder (R3)
Quotient (Qn-1) ÷ Base number = Quotient (Qn) + Remainder (Rn)
Repeat the process until the quotient of the division becomes 0.
b.Arranging the remainders in proper sequence to express the number in the new number system.
Use the following tips to express the number in the new number system:
•The remainder (R1) is placed in the least significant digit (LSD, right-most) position of the new base number.
•The remainder (R2) is placed in the second position from the right of the new base number.
•The last remainder (Rn) is the most significant digit (MSD, left-most digit) of the new base number.
The new base number is expressed as (Rn… R3R2R1)base number
This procedure can be applied to converting decimal numbers to all three other number systems: binary, octal, and hexadecimal.
3.6.1Converting Decimal to Binary
Converting a decimal number to its binary equivalent involves repeatedly dividing the decimal number by 2 until a quotient of 0 is obtained. Each remainder obtained is a digit of the equivalent binary number, starting from right to left.
Example 3.1: Converting decimal 125 to its binary equivalent
The procedure of converting 12510 to its binary equivalent is outlined below. The binary equivalent of 12510