Выбрать главу

an × 2n + an–1 × 2n–1 + an–2 × 2n–2 + ……… + a0 × 20

For example, binary number 11102 can be shown as:

11102 = 1 × 23 + 1 × 22 + 1 × 21 + 0 × 20

Similarly, binary number 100011102 can be shown as:

100011102 = 1 × 27 + 0 × 26 + 0 × 25 + 0 × 24 + 1 × 2+ 1 × 22 + 1 × 21 + 0 × 20

1.5.3 Octal Number System

In the octal number system, the valid numbers are 0, 1, 2, 3, 4, 5, 6, 7. A subscript 8 indicates that a number is in octal format. For example, the octal number 23 appears as 238.

In general, an octal number is represented as:

an × 8n + an–1 × 8n–1 + an–2 × 8n–2 + ……… + a0 × 80

For example, octal number 2378 can be shown as:

2378 = 2 × 82 + 3 × 81 + 7 × 80

Similarly, octal number 17778 can be shown as:

17778 = 1 × 83 + 7 × 82 + 7 × 81 + 7 × 80

1.5.4 Hexadecimal Number System

In the hexadecimal number system, the valid numbers are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. A subscript 16 or subscript H indicates that a number is in hexadecimal format. For example, hexadecimal number 1F can be written as 1F16 or as 1FH. In general, a hexadecimal number is represented as:

an × 16n + an–1 × 16n–1 + an–2 × 16n–2 + ……… + a0 × 160

For example, hexadecimal number 2AC16 can be shown as:

2AC16 = 2 × 162 + 10 × 161 + 12 × 160

Similarly, hexadecimal number 3FFE16 can be shown as:

3FFE16 = 3 × 163 + 15 × 162 + 15 × 161 + 14 × 160

1.6 Converting Binary Numbers into Decimal

To convert a binary number into decimal, write the number as the sum of the powers of 2.

Example 1.1

Convert binary number 10112 into decimal.

Solution 1.1

Write the number as the sum of the powers of 2:

10112 = 1 × 23 + 0 × 22 + 1 × 21 + 1 × 20

     = 8 + 0 + 2 = 1

     = 11

or, 10112 = 1110

Example 1.2

Convert binary number 110011102 into decimal.

Solution 1.2

Write the number as the sum of the powers of 2:

110011102 = 1 × 27 + 1 × 26 + 0 × 25 + 0 × 2+ 1 × 23 + 1 × 22 + 1 × 21 + 0 × 20

     = 128 + 64 + 0 + 0 + 8 + 4 + 2 + 0

     = 206

or, 110011102 = 20610

Table 1.1 shows the decimal equivalent of numbers from 0 to 31.

Table 1.1: Decimal equivalent of binary numbers

Binary Decimal Binary Decimal
00000000 0 00010000 16
00000001 1 00010001 17
00000010 2 00010010 18
00000011 3 00010011 19
00000100 4 00010100 20
00000101 5 00010101 21
00000110 6 00010110 22
00000111 7 00010111 23
00001000 8 00011000 24
00001001 9 00011001 25
00001010 10 00011010 26
00001011 11 00011011 27
00001100 12 00011100 28
00001101 13 00011101 29
00001110 14 00011110 30
00001111 15 00011111 31

1.7 Converting Decimal Numbers into Binary

To convert a decimal number into binary, divide the number repeatedly by 2 and take the remainders. The first remainder is the least significant digit (LSD), and the last remainder is the most significant digit (MSD).

Example 1.3

Convert decimal number 2810 into binary.

Solution 1.3