Su Chen Jonathon Lin

Programmable Logic Controllers


Скачать книгу

DivisionQuotientRemainder
125 ÷ 2621 (LSD)
62 ÷ 2310
31 ÷ 2151
15 ÷ 271
7 ÷ 231
3 ÷ 211
1 ÷ 201 (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.

DivisionQuotientRemainder
70 ÷ 2350 (LSD)
35 ÷ 2171
17 ÷ 281
8 ÷ 240
4 ÷ 220
2 ÷ 210
1 ÷ 201 (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:

DivisionQuotientRemainder
253 ÷ 8315 (LSD)
31 ÷ 837
3 ÷ 803 (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:

DivisionQuotientRemainder
895 ÷ 165515 (F) (LSD)
55 ÷ 1637
3 ÷ 1603 (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.

image

       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.

image

       Example 3.6: Converting 6278 to its decimal equivalent

      The decimal equivalent of 6278 is:

image

       3.6.6Converting Hexadecimal to Decimal

      The procedure of converting a hexadecimal number to its decimal equivalent starts by multiplying the place values (1, 161, 162,…, 16n) to their corresponding digits and summing the results. For example, the procedure of converting 5AC16 to decimal follows.

image

       Example 3.7: Converting B9516 to its decimal equivalent

      The decimal equivalent of B9516 is calculated as below:

image

       3.6.7Converting Binary to Octal

      Converting a binary number to its octal equivalent involves three steps (Figure 3.4). The first step separates the binary number into groups of three digits, starting from right to left. The second step assigns its octal equivalent for each three-digit group. The last step assembles the octal equivalent values in the proper sequence.

image

      Figure 3.4: Converting a binary number to its octal equivalent

       Example 3.8: Converting 110011012 to its octal equivalent

      110011012 has a total of 8 digits that can form three 3-digit groups with the third group having only 2 most significant digits. The binary digits in these three groups are:

image

      The octal equivalent of 110011012 becomes 3158.

       3.6.8Converting Octal to Binary

      Converting an octal number to its binary equivalent is the reverse of converting binary to octal. It involves the following two steps:

      •Convert each octal digit to its 3-digit equivalent.

      •Assemble the binary equivalent values in the proper sequence.

       Example 3.9: Converting 6358 to its binary equivalent

      The converting process follows:

image

      The binary equivalent of 6358 becomes 1100111012.

       3.6.9Converting Binary to Hexadecimal

      Converting a binary number to its hexadecimal equivalent involves the same three steps as converting binary to octal, except hexadecimal conversion involves 4-bit binary groupings. Four-bit groupings are used because each hexadecimal digit can be represented in four binary digits (Figure 3.5).

image

      Figure 3.5: Converting a binary number to its hexadecimal number

       Example 3.10: Converting 101100111010102 to its hexadecimal equivalent

      The binary 101100111010102 has 14 digits that can form four 4-bit groups with the fourth group having only 2 digits. The binary digits in these four groups are:

image