Название: Programmable Logic Controllers
Автор: Su Chen Jonathon Lin
Издательство: Ingram
Жанр: Физика
isbn: 9780831193690
isbn:
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 becomes 11111012.
Division | Quotient | Remainder |
---|---|---|
125 ÷ 2 | 62 | 1 (LSD) |
62 ÷ 2 | 31 | 0 |
31 ÷ 2 | 15 | 1 |
15 ÷ 2 | 7 | 1 |
7 ÷ 2 | 3 | 1 |
3 ÷ 2 | 1 | 1 |
1 ÷ 2 | 0 | 1 (MSD) |
Example 3.2: Converting decimal 70 to its binary equivalent
The procedure of converting 7010 to the binary number is listed below. The binary equivalent of 7010 becomes 10001102.
Division | Quotient | Remainder |
---|---|---|
70 ÷ 2 | 35 | 0 (LSD) |
35 ÷ 2 | 17 | 1 |
17 ÷ 2 | 8 | 1 |
8 ÷ 2 | 4 | 0 |
4 ÷ 2 | 2 | 0 |
2 ÷ 2 | 1 | 0 |
1 ÷ 2 | 0 | 1 (MSD) |
3.6.2Converting Decimal to Octal
Converting a decimal number to its octal equivalent involves repeatedly dividing the decimal number by 8 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.3: Converting decimal 253 to its octal equivalent
The procedure of converting 25310 to octal number is as follows:
Division | Quotient | Remainder |
---|---|---|
253 ÷ 8 | 31 | 5 (LSD) |
31 ÷ 8 | 3 | 7 |
3 ÷ 8 | 0 | 3 (MSD) |
The octal equivalent of 25310 is 3758.
3.6.3Converting Decimal to Hexadecimal
Converting a decimal number to its hexadecimal equivalent involves repeatedly dividing the decimal number by 16 until a quotient of 0 is reached. Each remainder obtained is a digit of the equivalent hexadecimal number, starting from right to left.
Example 3.4: Converting decimal 895 to its hexadecimal equivalent
The procedure of converting 89510 to hexadecimal number is as follows:
Division | Quotient | Remainder |
---|---|---|
895 ÷ 16 | 55 | 15 (F) (LSD) |
55 ÷ 16 | 3 | 7 |
3 ÷ 16 | 0 | 3 (MSD) |
The hexadecimal equivalent of 89510 becomes 37F16.
3.6.4Converting Binary to Decimal
The procedure of converting a binary number to its decimal equivalent starts by multiplying the place values to their corresponding digits and summing the results. The procedure of converting binary number 11012 to decimal follows. We can see that 11012 = 1310.
Example 3.5: Converting 110112 to its decimal equivalent
The decimal equivalent of 110112 is found as follows:
110112 = 1x24 + 1x23 + 0x22 + 1x21 + 1x20 = 16 + 8 + 0 + 2 + 1 = 2710
3.6.5Converting Octal to Decimal
The procedure of converting an octal number to its decimal equivalent starts with multiplying the place values (1, 81, 82,…, 8n) by their corresponding digits and summing the results. An example of converting octal number 5348 to its decimal equivalent follows.
Example 3.6: Converting 6278 to its decimal equivalent
The decimal equivalent of 6278 is: