PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 44

30 CHAPTER 2.

NUMBER SYSTEMS, OPERATIONS, AND CODES

Figure 2.1:

2. Convert decimal number 39 to binary.


Answer: 39 = 100111

3. Convert each decimal number to binary by using the sum-of-weights


method:
(a) 23 (b) 57 (c) 45.5
Answer:
(a) 23 = 10111 (b) 57 = 111001 (c) 45.5 = 101101.1

4. Convert each decimal number to binary by using the repeated division-


by-2 method (repeated multiplication-by-2 for fractions):
(a) 14 (b) 21 (c) 0.375
Answer: (a) 14 = 1110 (b) 21 = 10101 (c) 0.375 = 0.011

5. Convert each decimal number to binary by using the sum-of-weights


2.4. BINARY ARITHMETIC 31

method:
(a) 10 (b) 17 (c) 24 (d) 48
(e) 61 (f ) 93 (g) 125 (h) 186
Answer:
(a) 1010 (b) 10001 (c) 11000
(d) 110000 (e) 111101 (f ) 1011101
(g) 1111101 (h) 10111010

6. Convert each decimal number to binary using repeated division by 2:

(a) 15 (b) 21 (c) 28 (d) 34


(e) 40 (f ) 59 (g) 65 (h) 73

Answer:
(a) 1111 (b) 10101 (c) 11100
(d) 100010 (e) 101000 (f ) 111011
(g) 1000001 (h) 1001001

2.3.3 Unsolved Problems

1. Convert each decimal fraction to binary using the sum-of-weights method:


(a) 0.32 (b) 0.246 (c) 0.0981

2. Convert each decimal fraction to binary using repeated multiplication


by 2:
(a) 0.98 (b) 0.347 (c) 0.9028

2.4 Binary Arithmetic

2.4.1 Solved Examples

EXAMPLE 2-7
Add the following binary numbers:
(a) 11+11 (b) 100+10 (c) 111+11 (d) 110+100
Solution
The equivalent decimal addition is also shown for reference.

(a) 11 3 (b) 100 4 (c) 111 7 (d) 110 6


+11 +3 +10 +2 +11 +3 +100 +4
110 6 110 6 1010 10 1010 10
32 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

EXAMPLE 2-8
Perform the following binary subtractions:
(a) 11-01 (b) 11-10
Solution

(a) 11 3 (b) 11 3
−01 −1 −10 −2
10 2 01 1
No borrows were required in this example. The binary Number 01 is the
same as 1.

EXAMPLE 2-9
Subtract 011 from 101.

Solution

101 5
−011 −3
010 2
Let’s examine exactly what was done to subtract the two binary numbers
since a borrow is required. Begin with the right column as shown in Fig-
ure 2.2

Figure 2.2:
2.4. BINARY ARITHMETIC 33

EXAMPLE 2-10
Perform the following binary multiplications:

(a) 11 × 11 (b) 101 × 111


Solution

(a) 11 3 (b) 111 7


×11 ×3 ×101 ×5
P artial d 11 9 P artial d 111 35
products b +11 products | 000
1001 b +111
100011
EXAMPLE 2-11
Perform the following binary divisions:

(a) 110 ÷ 11 (b) 110 ÷ 10


Solution
The solution is shown in Figure 2.3.

Figure 2.3:

2.4.2 Answered Problems

1. Add 1111 and 1100.


Answer: 1111 + 1100 = 11011
34 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

2. Subtract 100 from 111.


Answer: 111 - 100 = 011

3. Subtract 101 from 110.


Answer: 110 - 101 = 001

4. Multiply
1101 × 1010
. Answer:
1101 × 1010 = 10000010

5. Divide 1100 by 100.


Answer:
1100 ÷ 100 = 11

6. Perform the following binary additions:


(a) 1101 + 1010 (b) 10111 + 01101
Answer: (a) 1101 + 1010 = 10111 (b) 10111 + 01101 = 100100

7. Perform the following binary subtractions:


(a) 1101 - 0100 (b) 1001 - 0111
Answer: (a) 1101 - 0100 = 1001 (b) 1001 - 0111 = 0010

8. Perform the indicated binary operations:

(a) 110 × 111 (b) 1100 ÷ 011


Answer:
(a) 110 × 111 = 101010
(b) 1100 ÷ 011 = 100

9. Add the binary numbers:

(a) 11 + 01 (b) 10 + 10 (c) 101 + 11


(d) 111 + 110 (e) 1001 + 101 (f ) 1101 + 1011

Answer:
(a) 100 (b) 100 (c) 1000
(d) 1101 (e) 1110 (f ) 11000
2.5. 1’S AND 2’S COMPLEMENTS OF BINARY NUMBERS 35

10.
(a) 11 × 11 (b) 100 × 10 (c) 111 × 101
(d) 1001 × 110 (e) 1101 × 110 (f ) 1110 × 1101
Answer:
(a) 1001 (b) 1000 (c) 100011
(d) 110110 (e) 10101001 (f ) 10110110

2.4.3 Unsolved Problems

1. Use direct subtraction on the following binary numbers:


(a) 11 − 1 (b) 101 − 100 (c) 110 − 101
(d) 1110 − 11 (e) 1100 − 1001 (f ) 11010 − 10111

2. Divide the binary numbers as indicated:


(a) 100 ÷ 10 (b) 1001 ÷ 11 (c) 1100 ÷ 100

2.5 1’s and 2’s Complements of Binary Numbers

2.5.1 Solved Examples

EXAMPLE 2-12
Find the 2’s complement of 10110010.

Solution

10110010 Binary N umber


01001101 10 s complement
+ 1 Add 1
01001110 20 s complement
EXAMPLE 2-13
Find the 2’s complement of 10111000 using the alternative method.

Solution

10111000 Binary N umber


0
1 s complements −→ 01001000 20 s complement
of original bits ↑
T hese bits stay the same.
36 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

2.5.2 Answered Problems

1. Determine the 2’s complement of 11001010.


Answer: 00110101

2. Find the 2’s complement of 11000000.


Answer: 01000000

3. Determine the 1’s complement of each binary number:


(a) 00011010 (b) 11110111 (c) 10001101
Answer:
(a) 1’s comp. of 00011010 = 11100101
(b) 1’s comp. of 11110111 = 00001000
(c) 1’s comp. of 10001101 = 01110010

4. Determine the 2’s complement of each binary number:


(a) 00010110 (b) 11111100 (c) 10010001
Answer:
(a) 2’s comp. of 00010110 = 11101010
(b) 2’s comp. of 11111100 = 00000100
(c) 2’s comp. of 10010001 = 01101111

5. Determine the 1’s complement of each binary number:

(a) 101 (b) 110 (c) 1010


(d) 11010111 (e) 1110101 (f ) 00001

Answer:
(a) 010 (b) 001 (c) 0101
(d) 00101000 (e) 0001010 (f ) 11110

2.5.3 Unsolved Problems

1. Determine the 2’s complement of each binary number:

(a) 10 (b) 111 (c) 1001 (d) 1101


(e) 11100 (f ) 10011 (g) 10110000 (h) 00111101
2.6. SIGNED NUMBERS 37

2.6 Signed Numbers

2.6.1 Solved Examples

EXAMPLE 2-14
Express the decimal number -39 as an 8-bit number in the sign-magnitude,
1’s complement, and 2’s complement forms.

Solution
First, write the 8-bit number for +39.

00100111

In the sign-magnitude form, -39 is produced by changing the sign bit to a 1


and leaving the magnitude bits as they are. The number is

10100111

In the 1’s complement form, -39 is produced by taking the 1’s complement
of +39 ()00100111.
11011000
In the 2’s complement form, -39 is produced by taking the 2’s complement
of +39 (00100111) as follows:

11011000 10 scomplement
+ 1
11011001 20 scomplement

EXAMPLE 2-15
Determine the decimal value of the signed binary number expressed in
sign-magnitude: 10010101.

Solution
The seven magnitude bits and their powers-of-two weights are as follows:

26 25 24 23 22 21 20
0 0 1 0 1 0 1
38 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

Summing the weights where there are 1s,

16 + 4 + 1 = 21

The sign bit is 1; therefore, the decimal number is -21.

EXAMPLE 2-16
Determine the decimal value of the signed binary number expressed in
1’s complement:
(a) 00010111 (b) 11101000
Solution
(a) The bits and their powers-of-two weights for the positive numbers are as
follows:
−27 26 25 24 23 22 21 20
0 0 0 1 0 1 1 1
Summing the weights where there are 1s,

16 + 4 + 2 + 1 = +23

(b) The bits and their powers-of-two weights for the negative numbers are
as follows. Notice that the negative sign bit has a weight of −27 or -128.

−27 26 25 24 23 22 21 20
1 1 1 0 1 0 0 0

Summing the weights where there are 1s,

−128 + 64 + 32 + 8 = −24

Adding 1 to the result, the final decimal number is

−24 + 1 = -23

EXAMPLE 2-17
Determine the decimal value of the signed binary number expressed in
2’s complement:
(a) 01010110 (b) 10101010
2.6. SIGNED NUMBERS 39

Solution
(a) The bits and their powers-of-two weight for the positive number are as
follows:
−27 26 25 24 23 22 21 20
0 1 0 1 0 1 1 0
Summing the weights where there are 1s.

64 + 16 + 4 + 2 = +86

(b) The bits and their power-of-two weights for the negative number are as
follows. Notice that the negative sign bit has a weight os −27 = -128.
−27 26 25 24 23 22 21 20
1 0 1 0 1 0 1 0
Summing the weights where there are 1s,

−128 + 32 + 8 + 2 = -86

EXAMPLE 2-18
Convert the decimal number

3.248 × 104

to a single-precision floating-point binary number.

Solution
Convert the decimal number to binary

3.248 × 104 = 32480 = 1111110111000002 = 1.11111011100000 × 214


The MSB will not occupy a bit position because it is always a 1. Therefore,
the mantissa is the fractional 23-bit binary number 11111011100000000000000
and the biased exponent is

14 + 127 = 141 = 100011012

To complete floating-point number is

0 100001101 11111011100000000000000
40 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

2.6.2 Answered Problems

1. Express +19 and -19 in sign-magnitude, 1’s complement, and 2’s com-
plement.
Answer: See Figure 2.4.

Figure 2.4:

2. Determine the decimal value of sign-magnitude number 01110111.


Answer: 01110111 - +1191 0

3. Determine the value of the 1’s complement number 11101011.


Answer: 11101011 = −201 0

4. Determine the decimal value of the 2’s complement number 11010111.


Answer: 11010111 = −411 0

5. Determine the binary value of the following floating-point binary num-


ber:
0 10011000 10000100010100110000000
Answer: 11000010001010011000000000

6. Express the decimal number +9 as an 8-bit binary number in the sign-


magnitude system.
Answer: Sign-magnitude: +9 = 00001001

7. Express the decimal number -33 as an 8-bit binary number in the 1’s
complement system.
Answer: 1’s comp.: -33 = 11011110

8. Express the decimal number -46 as an 8-bit binary number in the 2’s
complement system.
Answer: 2’s comp.: -46 = 11010010
2.6. SIGNED NUMBERS 41

9. List the three parts of a signed, floating-point number.


Answer: Sign bit, exponent, and mantissa.

10. Express each decimal number in binary as an 8-bit sign-magnitude


number:
(a) +29 (b) -85 (c) +100 (d) -123
Answer:
(a) 00011101 (b) 11010101
(c) 01100100 (d) 11111011

11. Express each decimal number as an 8-bit number in the 2’s complement
form:
(a) +12 (b) -68 (c) +101 (d) -125
Answer:
(a) 00001100 (b) 10111100
(c) 01100101 (d) 10000011

12. Determine the decimal value of each signed binary number in the 1’s
complement form:
(a) 10011001 (b) 01110100 (c) 10111111
Answer: (a) -102 (b) +116 (c) -64

13. Express each of the following sign-magnitude binary numbers in single-


precision floating-point format:
(a) 0111110000101011 (b) 100110000011000
Answer:
(a) 0 10001101 11110000101011000000000
(b) 1 10001010 11000001100000000000000

2.6.3 Unsolved Problems

1. Express each decimal number as an 8-bit number in the 1’s complement


form:
(a) -34 (b) +57 (c) -99 (d) +115

2. Determine the decimal value of each signed binary number in the sign-
magnitude form:
(a) 10011001 (b) 01110100 (c) 10111111
42 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

3. Determine the decimal value of each signed binary number in the 2’s
complement form:
(a) 10011001 (b) 01110100 (c) 10111111

4. Determine the value of the following single-precision floating-point num-


bers:
(a) 1 10000001 01001001110001000000000
(b) 0 11001100 100001111100100000000

2.7 Arithmetic Operations with Signed Numbers

2.7.1 Solved Examples

EXAMPLE 2-19
Add the signed numbers: 01000100, 00011011, 00001110, and 00010010.

Solution
The equivalent decimal additions are given for reference.

68 01000100
+ 27 + 00011011 Add 1st two numbers
95 01011111 1st sum
+ 14 + 00001110 Add 3rd number
109 01101101 2nd sum
+ 18 + 00010010 Add 4th number
127 01111111 F inal sum

EXAMPLE 2-20
Perform each of the following subtractions of the signed numbers:
(a) 00001000 - 00000011 (b) 00001100 - 11110111
(c) 11100111 - 00010011 (d) 10001000 - 11100010

Solution
Like in the other examples, the equivalent decimal subtractions are given for
reference.
2.7. ARITHMETIC OPERATIONS WITH SIGNED NUMBERS 43

(a) In this case, 8 - 3 = 8 + (-3) = 5.


00001000 M inuend (+8)
+ 11111101 20 s complement of subtrahend (−3)
Discard carry −→ 1 00000101 Dif f erence (+5)

(b) In this case, 12 - (-9) = 12 + 9 = 21.


00001100 M inuend (+12)
+ 00001001 20 s complement of subtrahend (+9)
00010101 Dif f erence (+21)

(c) In this case, -25 - (+19) = -25 + (-19) = -44.


11100111 M inuend (−25)
+ 11101101 20 s complement of subtrahend (−19)
Discard carry −→ 1 11010100 Dif f erence (−44)

(d) In this case, -120 - (-30) = -120 + 30 = -90.


10001000 M inuend (−120)
+ 00011110 20 s complement of subtrahend (+30)
10100110 Dif f erence (−90)

EXAMPLE 2-21
Multiply the signed binary numbers: 01001101 (multiplicand)and 00000100
(multiplier) using the direct addition method.

Solution
Since both numbers are positive, they are in true form, and the product will
be positive. The decimal value of the multiplier is 4, so the multiplicand is
added to itself four times as follows:
01001101 1st time
+ 01001101 2nd time
10011010 P artial sum
+ 01001101 3rd time
11100111 P artial sum
+ 01001101 4th time
100110100 P roduct
44 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

Since the sign bit of the multiplicand is 0, it has no effect on the outcome.
All of the bits in the product are magnitude bits.

EXAMPLE 2-22
Multiply the signed binary numbers: 01010011 (multiplicand)and 11000101
(multiplier).

Solution
Step 1: The sign bit of the multiplicand is 0 and the sign bit of the multiplier
is 1. The sign bit of the product will be 1 (negative).

Step 2: Take the 2’s complement of the multiplier to put it in true form.
11000101 −→ 00111011
Step 3 and 4: The multiplication proceeds as follows. Notice that only the
magnitude bits are used in these steps.
1010011 M ultiplicand
× 0111011 M ultiplier
1010011 1st partial product
+ 1010011 2nd partial product
11111001 Sum of 1st and 2nd
+ 0000000 3rd partial product
011111001 Sum
+ 1010011 4th partial product
1110010001 Sum
+ 1010011 5th partial product
100011000001 Sum
+ 1010011 6th partial product
1001100100001 Sum
+ 0000000 7th partial product
1001100100001 F inal product
Step 5: Since the sign of the product is 1 as determined in step 1, take the
2’s complement of the product.
1001100100001 −→ 0110011011111
1 0110011011111

2.7. ARITHMETIC OPERATIONS WITH SIGNED NUMBERS 45

Attach the sign bit

EXAMPLE 2-23
Divide 01100100 by 00011001.

Solution
Step 1: The signs of both numbers are positive, so the quotient will positive.
The quotient is initially zero: 00000000.
Step 2: Subtract the divisor from the division using 2’s complement addition
(remember that final carries are discarded).
01100100 Dividen
+ 11100111 20 s complement of divisor
01001011 P ositive 1st partial remainder
Add 1 to quotient: 00000000 + 00000001 = 00000001.
Step 3: Subtract the divisor from the 1st partial remainder using 2’s com-
plement addition.
01001011 1st partial reminder
+ 11100111 20 s complement of divisor
00110010 P ositive 2nd partial reminder
Step 4: Subtract the divisor from the 2nd partial remainder using 2’s com-
plement addition.
00110010 2nd partial reminder
+ 11100111 20 s complement of divisior
00011001 P ositive 3rd partial reminder
Add 1 to quotient: 00000010 + 00000001 = 00000011.
Step 5: Subtract the divisor from the 3rd partial reminder using 2’s com-
plement addition.
00011001 3rd partial reminder
+11100111 20 s complement of divisor
00000000 Zero reminder

Add 1 to quotient: 00000011 + 00000001 = 00000100 (final quotient). The


process is complete.
46 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

2.7.2 Answered Problems

1. Add 00110011, 10111111, and 01100011. These are signed numbers.


Answer: 01010101

2. Subtract 01000111 from 01011000.


Answer: 00010001

3. Multiply 01100001 by 00000110 using the direct addition method.


Answer: 1001000110

4. Verify the multiplication is correct (of Example 2-22) by converting to


decimal numbers and performing the multiplication.
Answer:
(83)(-59)=-4897 (10110011011111 in 2’s comp.)
5. Verify that the process is correct (of Example 2-23) by converting to
decimal numbers and performing the division.
Answer:
100 × 25 = 4(0100)

6. List the four cases when numbers are added.


Answer: Case of addition: positive number is larger, negative number
is larger, both are positive, both are negative.
7. Add 00100001 and 10111100.
Answer: 00100001 + 10111100 = 11011101

8. Subtract 00110010 from 01110111.


Answer: 01110111 - 00110010 = 01000101

9. What is the sign of the product when two negative numbers are multi-
plied?
Answer: Sign of product is positive.

10. Multiply 01111111 by 00000101.


Answer:
00000101 × 01111111 = 01001111011

11. What is the sign of the quotient when a positive number is divided by
a negative number?
Answer: Sign of quotient is negative.
2.8. HEXADECIMAL NUMBERS 47

12. Divide 00110000 by 00001100.


Answer:
00110000 ÷ 00001100 = 00000100

13. Convert each pair of decimal numbers to binary and add using the 2’s
complement form:
(1) 33 and 15 (b) 56 and -27 (c) -46 and 25 (d)-110 and -84
Answer:
(a) 00110000 (b) 00011101
(c) 11101011 (d) 100111110

14. Perform each addition in the 2’s complement form:


(a) 10001100 + 00111001 (b) 11011001 + 11100111
Answer: (a) 11000101 (b) 11000000

15. Multiply 01101010 by 11110001 in the 2’s complement form.


Answer: 100111001010

2.7.3 Unsolved Problems

1. Perform each addition in the 2’s complement form:


(a) 00010110 + 00110011 (b) 01110000 + 10101111

2. Perform each subtraction in the 2’s complement form:


(a) 00110011 - 00010000 (b) 01100101 - 11101000

3. Divide 01000100 by 00011001 in the 2’s complement form.

2.8 Hexadecimal Numbers

2.8.1 Solved Examples

2.8.2 Solved Examples

EXAMPLE 2-24
Convert the following binary numbers to hexadecimal:
(a) 1100101001010111 (b) 111111000101101001
48 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

Solution

(a) 1100
| {z } 1010
| {z } 0101
| {z } 0111
| {z } (b) 0011
| {z } 1111
| {z } 0001
| {z } 0110
| {z } 1001
| {z }
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
C A 5 7 = CA5716 3 F 1 6 9 = 3F16916

Two zeros have been added in part (b) to complete a 4-bit group at the left.

EXAMPLE 2-25
Determine the binary numbers for the following hexadecimal numbers:
(a) 10A416 (b) CF 8E16 (c) 974216

Solution

(a) 1 0 A 4 (b) C F 8 E (c) 9 7 4 2


↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
z }| { z }| { z }| { z }| { z }| { z }| { z }| { z }| { z }| { z }| { z }| {
1 0000 1010 0100 1100 1111 1000 1110 1001 1011 0100 0010

In part (a), the MSB is understood to have three zeros preceding it, thus
forming a 4-bit group.

EXAMPLE 2-26
Convert the following hexadecimal numbers to decimal:
(a) 1C16 (b) A8516

Solution

Remember, convert the hexadecimal number to binary first, then to dec-


imal.
2.8. HEXADECIMAL NUMBERS 49

(a) 1 C
↓ ↓
z }| { z }| {
0001 1100 = 24 + 23 + 22 = 16 + 8 + 4 = 2810

(b) A 8 5
↓ ↓ ↓
z }| { z }| { z }| {
1010 1000 0101 = 211 + 29 + 27 + 22 + 20 = 2048 + 512 + 128 + 4 + 1 = 269310

EXAMPLE 2-27
Convert the following hexadecimal numbers to decimal:
(a) E516 (b) B2F 816

Solution

Recall from Figure 2.5 that letters A through F represent decimal numbers
10 through 15, respectively.

(a) E516 = (E × 16) + (5 × 1) = (14 × 16) + (5 × 1) = 224 + 5 = 22910

(b) B2F 816 = (B × 4096) + (2 × 256) + (F × 16) + (8 × 1)


= (11 × 4096) + (2 × 256) + (15 × 16) + (8 × 1)
= 45, 056 + 512 + 240 + 8 = 45,81610

EXAMPLE 2-28
Convert the decimal number 650 to hexadecimal by repeated division by
16.

Solution
The solution is shown in Figure 2.6.
EXAMPLE 2-29
Add the following hexadecimal numbers:
(a) 2316 + 1616 (b) 5816 + 2216 (c) 2B16 + 8416 (d) DF16 + AC16
50 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

Figure 2.5:

Figure 2.6:

Solution
2.8. HEXADECIMAL NUMBERS 51

(a) 2316 right column : 316 + 616 = 310 + 610 = 910 = 916
+1616 lef t column : 216 + 116 = 2010 + 110 = 310 = 316
3916

(b) 5816 right column : 816 + 216 = 810 + 210 = 1010 = A16
+3316 lef t column : 516 + 216 = 510 + 210 = 710 = 716
7A16

(c) 2B16 right column : B16 + 416 = 1110 + 410 = 1510 = F16
+8416 lef t column : 216 + 816 = 210 + 810 = 1010 = A16
AF16

(d) DF16 right column : F16 + C16 = 1510 + 1210 = F10


+AC16 2710 − 1610 = 1110 = B16 with a 1 carry
18B16 lef t column : D16 + A16 + 116 = 1310 + 1010 + 110 = 2410
2410 − 1610 = 810 = 816 with a 1 carry

EXAMPLE 2-30
Subtract the following hexadecimal numbers:
(a) 8416 - 2A16 (b) C316 - 0B16

Solution
(a) 2A16 = 00101010

2’s complement of 2A16 = 11010110 = D616 ........(Using Method 1)

8416
+ D616 Add
1 5A16 Drop carry, as in 20 s complement addition

The difference is 5A16 .

(b) 0B16 = 00001011


52 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

2’s complement of 0B16 = 11110101 = F 516 ........(Using Method 1)

C316
+ F 516 Add
1 B816 Drop carry

The difference is B816 .

2.8.3 Answered Problems

1. Convert the binary number 1001111011110011100 to hexadecimal.


Answer: 4F 79C16

2. Convert the hexadecimal number 6BD3 to binary.


Answer: 01101011110100112

3. Convert the hexadecimal number 6BD to decimal.


Answer:

6BD16 = 011010111101 = 21 0 + 29 + 27 + 25 + 24 + 23 + 22 + 20
= 1024 + 512 + 128 + 32 + 16 + 8 + 4 + 1 = 172510

4. Convert 60A16 to decimal.


Answer: 60A16 = (6 × 256) + (0 × 16) + (10 × 1) = 154610

5. Convert decimal 2591 to hexadecimal.


Answer: 259110 = A1F16

6. Add 4C16 and 3A16 .


Answer: 4C16 + 3A16 = 8616

7. Subtract 17316 from BCD16 .


Answer: BCD16 − 17316 = A5A16

8. Convert the following binary numbers to hexadecimal:


(a) 10110011 (b) 110011101000
Answer:
(a) 10110011 = B316 (b) 110011101000 = CE816
2.8. HEXADECIMAL NUMBERS 53

9. Convert the following hexadecimal numbers to binary:


(a) 5716 (b) 3A516 (c) F 80B16
Answer:
(a) 5716 = 01010111 (b) 3A516 = 001110100101
(c) F 8OB16 = 1111100000001011

10. Convert 9B3016 to decimal.


Answer: 9B3016 = 39, 72810

11. Convert the decimal number 573 to hexadecimal.


Answer: 57310 = 23D16

12. Add the following hexadecimal numbers directly:


(a) 1816 + 3416 (b) 3F16 + 2A16
Answer:
(a) 1816 + 3416 = 4C16 (b) 3F16 + 2A16 = 6916

13. Subtract the following hexadecimal numbers:


(a) 7516 - 2116 (b) 9416 - 5C16
Answer:
(a) 7516 − 2116 = 5416 (b) 9416 − 5C16 = 3816

14. Convert each hexadecimal number to binary:

(a) 3816 (b) 5916 (c) AI416 (d) 5C816


(e) 410016 (f ) F B1716 (g) 8A9D16
Answer:
(a) 00111000
(b) 01011001
(c) 101000010100
(d) 010111001000
(e) 0100000100000000
(f ) 1111101100010111
(g) 1000101010011101

15. Convert each hexadecimal number to decimal:

(a) 2316 (b) 9216 (c) 1A16 (d) 8D16


(e) F 316 (f ) EB16 (g) 5C216 (g) 70016
54 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

Answer:
(a) 35 (b) 146 (c) 26 (d) 141
(e) 243 (f ) 235 (g) 1474 (g) 1792

16. Perform the following additions:


(a) 3716 + 2916 (b) A016 + 6B16 (c) F F16 + BB16
Answer: (a) 6016 (b) 10B16 (c) 1BA16

2.8.4 Unsolved Problems

1. Convert each binary number to hexadecimal:


(a) 1110 (b) 10 (c) 10111
(d) 10100110 (e) 1111110000 (f ) 100110000010

2. Convert each decimal number to hexadecimal:


(a) 8 (b) 14 (c) 33 (d) 52
(e) 284 (f ) 2890 (g) 4019 (h) 6500

3. Perform the following subtractions:


(a) 5116 − 4016 (b) C816 − 3A16 (c) F D16 − 8816

2.9 Octal Numbers

2.9.1 Solved Examples

EXAMPLE 2-31
Convert each of the following octal numbers to binary:
(a) 138 (b) 258 (c) 1408 (d) 75268

Solution

(a) 1 3 (b) 2 5 (c) 1 4 0 (d) 7 5 2 6


↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
z}|{ z}|{ z}|{ z}|{ z}|{ z}|{ z}|{ z}|{ z}|{ z}|{ z}|{
001 011 010 101 001 100 000 111 101 010 110
EXAMPLE 2-32
Convert each of the following binary numbers to octal:
(a) 110101 (b) 101111001 (c) 100110011010 (d) 11010000100
2.9. OCTAL NUMBERS 55

Solution

(a) |{z}
110 |{z}
101 (b) |{z}
101 |{z}
111 |{z}
001
↓ ↓ ↓ ↓ ↓
6 5 = 658 5 7 1 = 5718

(c) |{z}
100 |{z}
110 |{z}
011 |{z}
010 (d) |{z}
011 |{z}
010 |{z}
000 |{z}
100
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
4 6 3 2 = 46328 3 2 0 4 = 32048

2.9.2 Answered Problems

1. Convert each of the binary numbers to decimal (of EXAMPLE 2-31)


and verify that each value agrees with the decimal value of the corre-
sponding octal number.
Answer:

(a) 0010112 = 1110 = 138 (b) 0101012 = 2110 = 258


(c) 0011000002 = 9610 = 1408 (d) 1111010101102 = 392610 = 75268

2. Convert binary number 1010101000111110010 to octal.


Answer: 12507628

3. Convert the following octal numbers to decimal:


(a) 738 (b) 1258
Answer: (a) 738 = 5910 (b) 1258 = 8510

4. Convert the following decimal numbers to octal:


(a) 9810 (b) 16310
Answer: (a) 9810 = 1428 (b) 16310 = 2438

5. Convert the following octal numbers to binary:


(a) 468 (b) 7238 (c) 56248
Answer:
(a) 468 = 100110 (b) 7238 = 111010011 (c) 56248 = 101110010100
56 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

6. Convert the following binary numbers to octal:


(a) 110101111 (b) 1001100010 (c) 10111111001
Answer: (a) 110101111 = 6578 (b) 1001100010 = 11428
(c) 10111111001 = 27718
7. Convert each octal number to decimal:
(a) 128 (b) 278 (c) 568 (d) 648 (e) 1038
(f ) 5578 (g) 1638 (h) 10248 (i) 77658
Answer:
(a) 10 (b) 23 (c) 46 (d) 52 (e) 67
(f ) 367 (g) 115 (h) 532 (i) 4085

8. Convert each octal number to binary:


(a) 138 (b) 578 (c) 1018 (d) 3218 (e) 5408
(f ) 46538 (g) 132718 (h) 456008 (i) 1002138
Answer:
(a) 001011
(b) 101111
(c) 001000001
(d) 011010001
(e) 101100000
(f ) 100110101011
(g) 001011010111001
(h) 100101110000000
(i) 001000000010001011

2.9.3 Unsolved Problems

1. Convert each decimal number to octal by repeated division by 8:

(a) 15 (b) 27 (c) 46 (d) 70


(f ) 100 (g) 142 (h) 219 (i) 435
2. Convert each binary number to octal:

(a) 111 (b) 10 (c) 110111


(d) 101010 (e) 1100 (f ) 1011110
(g) 101100011001 (h) 10110000011 (i) 111111101111000
2.10. BINARY CODED DECIMAL (BCD) 57

2.10 Binary Coded Decimal (BCD)

2.10.1 Solved Examples

EXAMPLE 2-33
Convert each of the following decimal numbers to BCD:
(a) 35 (b) 98 (c) 170 (d) 2469

Solution

(a) 3 5 (b) 9 8
↓ ↓ ↓ ↓
z }| { z }| { z }| { z }| {
0011 0101 1001 1000

(c) 1 7 0 (d) 2 4 6 9
↓ ↓ ↓ ↓ ↓ ↓ ↓
z }| { z }| { z }| { z }| { z }| { z }| { z }| {
0001 0111 0000 0010 0100 0110 1001

EXAMPLE 2-34
Convert each of the following BCD codes to decimal:
(a) 10000110 (b) 001101010001 (c) 1001010001110000

Solution

| {z } 0110
(a) 1000 | {z } (b) 0011
| {z } 0101
| {z } 0001
| {z } (c) 1001
| {z } 0100
| {z } 0111
| {z } 0000
| {z }
↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
8 6 3 5 1 9 4 7 0

EXAMPLE 2-35
Add the following BCD numbers:
(a) 0011 + 0100 (b) 00100011 + 00010101
(c) 10000110 + 00010011 (d) 010001010000 + 010000010111

Solution
58 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

The decimal number additions are shown for comparison.

(a) 0011 3 (b) 0010 0011 23


+ 0100 +4 + 0001 0101 + 15
0111 7 0011 1000 38

(c) 1000 0110 86 (d) 0100 0101 0000 450


+ 0001 0011 + 13 + 0100 0001 0111 + 417
1001 1001 99 1000 0110 0111 867

Note that in each case the sum in any 4-bit column does not exceed 9, and
the results are valid BCD numbers.

EXAMPLE 2-36

Add the following BCD numbers:


(a) 1001 + 0100 (b) 1001 + 1001
(c) 00010110 + 00010101 (d) 01100111 + 01010011

Solution
2.10. BINARY CODED DECIMAL (BCD) 59

The decimal number addition are shown for comparison.

(a) 1001 9
+ 0100 +4
1101 Invalid BCDnumber(> 9) 13
+ 0110 Add 6
0001
| {z } 0011
| {z } V alid BCD number
↓ ↓
1 3

(b) 1001 9
+ 1001 +9
1 0010 Invalid because of carry 18
+ 0110 Add 6
0001
| {z } 1000
| {z } V alid BCD number
↓ ↓
1 8

(c) 0001 0110 16


+ 0001 0101 + 15
0010 1011 Right group is invalid (> 9), 31
lef t group is valid
+ 0110 Add 6 to invalid code. Add
carry, 0001 to next group.
0011
| {z } 0001
| {z } V alid BCD number
↓ ↓
3 1

(d) 0110 0111 67


+ 0101 0011 + 53
1011 1010 Both groups are invalid (> 9) 120
+ 0110 + 0110 Add 6 to both groups
0001
| {z } 0010
| {z } 0000
| {z } V alid BCD number
↓ ↓ ↓
1 2 0
60 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

2.10.2 Answered Problems

1. Convert the decimal number 9673 to BCD.


Answer: 100101100111001

2. Convert the BCD code 10000010001001110110 to decimal.


Answer: 82, 27610

3. Add the BCD numbers: 100100001000011 + 0000100100100101.


Answer: 1001100101101000

4. Add the BCD numbers: 01001000 + 00110100.


Answer: 10000010

5. What is the binary weight of each 1 in the following BCD numbers?


(a) 0010 (b) 1000 (c) 0001 (d) 0100
Answer: (a) 0010:2 (b) 1000:8 (c) 0001:1 (d)0100:4

6. Convert the following decimal numbers to BCD:


(a) 6 (b) 15 (c)273 (d) 849
Answer:
(a) 610 = 0110 (b) 1510 = 00010101
(c) 27310 = 001001110011 (d) 84710 = 100001001001

7. What decimal numbers are represented by each BCD code?


(a) 10001001 (b) 001001111000 (c) 000101010111
Answer:
(a) 10001001 = 8910 (b) 001001111000 = 27810
(c) 000101010111 = 15710

8. In BCD addition, when is a 4-bit sum invalid?


Answer: A 4-bit sum is invalid when it is grater than 910 .

9. Convert each of the following decimal numbers to 8421 BCD:

(a) 10 (b) 13 (c) 18 (d) 21 (e) 25 (f ) 36


(g) 44 (h) 57 (i) 69 (j) 98 (k) 125 (l) 156
2.10. BINARY CODED DECIMAL (BCD) 61

Answer:
(a) 00010000 (b) 00010011
(c) 00011000 (d) 00100001
(e) 00100101 (f ) 00110110
(g) 01000100 (h) 01010111
(i) 01101001 (j) 10011000
(k) 000100100101 (l) 000101010110

10. Convert the following decimal numbers to BCD:

(a) 104 (b) 128 (c) 132 (d) 150 (e) 186
(f ) 210 (g) 359 (h) 547 (i) 1051

Answer:

(a) 000100000100 (b) 000100101000


(c) 000100110010 (d) 000101010000
(e) 000110000110 (f ) 001000010000
(g) 001101011001 (h) 010101000111
(i) 0001000001010001

11. Convert each of the BCD numbers to decimal:

(a) 10000000 (b) 001000110111


(c) 001101000110 (d) 01000010001
(e) 011101010100 (f ) 100000000000
(g) 100101111000 (h) 0001011010000011
(i) 10010000000 (j) 0110011001100111

Answer:
(a) 80 (b) 237 (c) 346 (d) 421
(e) 754 (f ) 800 (g) 978 (h) 1683
(i) 9018 (j) 6667

12. Add the following BCD numbers:

(a) 1000 + 0110 (b) 0111 + 0101


(c) 1001 + 1000 (d) 1001 + 0111
(e) 00100101 + 00100111 (f ) 01010001 + 01011000
(g) 10011000 + 10010111 (h) 010101100001 + 011100001000
62 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

Answer:

(a) 00010100 (b) 00010010


(c) 0001011 (d) 00010110
(e) 01010010 (f ) 000100001001
(g) 000110010101 (h) 0001001001101001

2.10.3 Unsolved Problems

1. Convert each of the following decimal numbers to straight binary, and


compare the number of bits required with that required for BCD.

(a) 10 (b) 13 (c) 18 (d) 21 (e) 25 (f ) 36


(g) 44 (h) 57 (i) 69 (j) 98 (k) 125 (l) 156

2. Convert each of the BCD numbers to decimal:


(a) 0001 (b) 0110 (c) 1001
(d) 00011000 (e) 00011001 (f ) 00110010
(g) 01000101 (h) 10011000 (i) 100001110000

3. Add the following BCD numbers:

(a) 0010 + 0001 (b) 0101 + 0011


(c) 0111 + 0010 (d) 1000 + 0001
(e) 00011000 + 00010001 (f ) 01100100 + 00110011
(g) 01000000 (h) 10000101 + 00010011

4. Convert each pair of decimal numbers to BCD, and add as indicated:

(a) 4 + 3 (b) 5 + 2 (c) 6 + 4 (d) 17 + 12


(e) 28 + 23 (f ) 65 + 58 (g) 113 + 101 (h) 295 + 157

2.11 Digital Codes

2.11.1 Solved Examples

EXAMPLE 2-37
(a) Convert the binary number 11000110 to Gray code.
(b) Convert the Gray code 10101111 to binary.
2.11. DIGITAL CODES 63

Figure 2.7:

Solution
The solution is as shown in Figure 2.7.
EXAMPLE 2-38
Determine the binary ASCII codes that are entered from the computer’s
keyboard when the following BASIC program statement is typed in. Also
express each code in hexadecimal.

20 P RIN T ”A = ”; X
Solution
The ASCII code for each symbol is found in Figure 2.8.
Symbol Binary Hexadecimal
2 0110010 3216
0 0110000 3016
Space 0100000 2016
P 1010000 5016
R 1010010 5216
I 1001001 4916
N 1001110 4E16
T 1010100 5416
Space 0100000 2016
” 0100010 2216
A 1000001 4116
= 0111101 3D16
” 0100010 2216
; 0111011 3B16
X 1011000 5816
64 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

Figure 2.8:
2.11. DIGITAL CODES 65

2.11.2 Answered Problems

1. (a) Convert binary 101101 to Gray code.


(b) Convert Gray code 100111 to binary.
Answer: (a) 111011 (Gray) (b) 1110102

2. Determine the sequence of ASCII codes required for the following pro-
gram statement and express them in hexadecimal:
80 IN P U T Y
Answer: The sequence of codes for 80 INPUTY is
3816 3016 2016 4916 4E16 5016 5516 5416 2016 5916
3. Convert the following binary numbers to the Gray Code:
(a) 1100 (b) 1010 (c) 11010
Answer:
(a) 11002 = 1010 Gray (b) 10102 = 1111 Gray
(c) 110102 = 10111 Gray
4. Convert the following Gray codes to binary:
(a) 1000 (b) 1010 (c) 11101
Answer:
(a) 1000 Gray = 11112 (b) 1010 Gray = 11002
(c) 11101 Gray = 101102
5. What is the ASCII representation for each of the following characters?
Express each as a bit pattern and in hexadecimal notation.
(a) K (b) r (c) $ (d) +
Answer:
(a) 1001011 → 4B16 (b) 1110010 → 7216
(c) 0100100 → 2416 (d) 0101011 → 2B1 6

6. In a certain application a 4-bit binary sequence cycle from 1111 to


0000 periodically. There are four bit changes, and because of circuit
delays, these changes may not occur at the same instant. For example,
if the LSB changes first, the number will appears as 1110 during the
transition from 1111 to 0000 and may be misinterpreted by the system.
Illustrate how the Gray code avoids this problem.
Answer: The Gray code makes only one bit change at a time when
going from one number in the sequence to the next.
66 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

7. Convert each Gray code to binary:


(a) 1010 (b) 00010 (c) 11000010001
Answer:
(a) 1100 (b) 00011 (c) 10000011110
8. Determine each ASCII character. Refer to Figure 2.8
(a) 0011000 (b) 1001010 (c) 0111101
(d) 0100011 (e) 0111110 (f ) 1000010
Answer:
(a) CAN (b) J (c) =
(d) # (e) > (f ) B
9. Write the following ASCII coded message in hexadecimal:
1001000 1100101 1101100 1101100 1101111 0101110
0100000 1001000 1101111 1110111 0100000 1100001
1110010 1100101 0100000 1111001 1101111 1110101
0111111
Answer:
48 56 6C 6F 2E 20 48 6F 77 20 61 72 65 20 79 6F 75 3D

2.11.3 Unsolved Problems

1. Convert each binary number to Gray code:


(a) 11011 (b) 1001010 (c) 1111011101110
2. Convert each of the following decimal numbers to ASCII. Refer to Fig-
ure 2.8.
(a) 1 (b) 3 (c) 6 (d) 10 (e) 18
(f ) 29 (g) 56 (h) 75 (i) 107
3. Decode the following ASCII coded message:
1001000 1100101 1101100 1101100 1101111 0101110
0100000 1001000 1101111 1110111 0100000 1100001
1110010 1100101 0100000 1111001 1101111 1110101
0111111

4. Convert the following computer program statement to ASCII:


30 IN P U T A, B
2.12. ERROR DETECTION AND CORRECTION CODES 67

2.12 Error Detection and Correction Codes

2.12.1 Solved Examples

EXAMPLE 2-39
Assign the proper even parity bit to the following code groups:
(a) 1010 (b) 111000 (c) 101101
(d) 1000111001001 (e) 101101011111
Solution
Make the parity bit either 1 or 0 as necessary to make the total number of
1s even. The parity bit will be the left-most bit (bold).

(a) 01010 (b) 1111000 (c) 0101101


(d) 01000111001001 (e) 1101101011111

EXAMPLE 2-40
An odd parity system receives the following code group: 10110, 11010,
110011, 110101110100, and 1100010101010. Determine which group, if any,
are in error.

Solution
Since odd parity is required, any group with an even number of 1s is incor-
rect. The following groups are in error: 110011 and 1100010101010.

EXAMPLE 2-41
Determine the Hamming code for the BCD number 1001 (data bits), us-
ing even parity.

Solution
Step 1: Find the number of parity bits required. Let p = 3. Then

2p = 23 = 8

d+p+1=4+3+1=8
Three parity bits are sufficient.

T otal code bits = 4 + 3 = 7


68 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

Figure 2.9:

Step 2: Construct a bit position table, as shown in Figure 2.9, and enter
the data bits. Parity bits are determined in the following steps.
Step 3: Determine the parity bits as follows:

Bit P1 checks bit positions 1,3,5, and 7 and must be a 0 for there to be
an even number of 1s (2) in this group.

Bit P2 checks bit positions 2,3,6, and 7 and must be a 0 for there to be
an even number of 1s (2) in this group.

Bit P3 checks bit positions 4,5,6, and 7 and must be a 0 for there to be
an even number of 1s (2) in this group.

Step 4: These parity bits are entered in Figure 2.9, and the resulting com-
bined code is 0011001.

EXAMPLE 2-42
Determine the Hamming code for the data bits 10110 using even parity.
Solution
Step 1: Determine the number of parity bits required. In this case the
number of data bits, d, is five. From the previous example we know that
p = 3 will not work. Try p = 4:
2p = 24 = 16
d + p + 1 = 5 + 4 + 1 = 10
Four parity bits are sufficient.
T otal code bits = 5 + 4 = 9
2.12. ERROR DETECTION AND CORRECTION CODES 69

Step 2: Construct a bit position table shown in Figure 2.10, and enter the
data bits. Parity bits are determined in the following steps. Notice that P4
is in bit position 8.

Figure 2.10:

Step 3: Determine the parity bits as follows:

Bit P1 checks bit positions 1,3,5,7, and 9 and must be a 1 for there to be an
odd number of 1s (3)in this group.

Bit P2 checks bit positions 2,3,7, and 7 and must be a 1 for there to be
an odd number of 1s (3)in this group.

Bit P3 checks bit positions 4,5,6, and 9 and must be a 1 for there to be
an odd number of 1s (3)in this group.

Bit P4 checks bit positions 8 and 9 and must be a 1 for there to be an


odd number of 1s (3)in this group.

Step 4: These parity bits are entered in Figure 2.10, and the resulting
combined code is 101101110.

EXAMPLE 2-43
Assume that the code word in Example 2-41 (0011001)is transmitted and
that 0010001 is received. The receiver does not ”know” what was transmit-
ted and must look for proper parities to determine if the code is correct.
Designate any error that has occurred in transmission if even parity is used.

Solution
70 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

First, make a bit position table, as indicated in Figure 2.11.

Figure 2.11:

First parity check:


Bit P1 checks positions 1,3,5, and 7.
There are two 1s in this group.
Parity check is good. → 0(LSB)

Second parity check:


Bit P2 checks positions 2,3,6, and 7.
There are two 1s in this group.
Parity check is good. →0

Third parity check:


Bit P3 checks positions 4,5,6, and 7.
There is one 1 in this group.
Parity check is bad. → 1(MSB)

Result: The error position code is 100 (binary four). This says that the
bit in position 4 is in error. It is a 0 and should be a 1. The corrected code
is 0011001, which agrees with the transmitted code.

EXAMPLE 2-44
The code 101101010 is received. Correct any errors. There are four parity
bits, and odd parity is used.

Solution

First, make a bit position table like Figure 2.12.


2.12. ERROR DETECTION AND CORRECTION CODES 71

Figure 2.12:

First parity check:


Bit P1 checks positions 1,3,5,7, and 9.
There are two 1s in this group.
Parity check is good. → 1(LSB)

Second parity check:


Bit P2 checks positions 2,3,6, and 7.
There are two 1s in this group.
Parity check is bad. →1

Third parity check:


Bit P3 checks positions 4,5,6, and 7.
There are two 1s in this group.
Parity check is bad. →1

Fourth parity check:


Bit P4 checks positions 8 and 9.
There is one 1 in this group.
Parity check is good. → 0(MSB)

Result: The error position code is 0111 (binary seven). This says that
the bit in position 7 is in error. The corrected code therefore 101101110.

2.12.2 Answered Problems

1. Add an even parity bit to the 7-bit ASCII code for the letter K.
Answer: 01001011

2. The following ASCII character is received by an odd parity system:


00110111. Is it correct?
72 CHAPTER 2. NUMBER SYSTEMS, OPERATIONS, AND CODES

Answer: Yes.

3. Determine the Hamming code for the BCD numbers 1000 using even
parity.
Answer: 1110000

4. Determine the Hamming code for 11001 using odd parity.


Answer: 001010001

5. Repeat the process illustrated in Example 2-43 if the received code is


0111001.
Answer: The bit in position 010(2) is in error. Correct to 0011001.

6. The code 101111001 is received. Correct any error if odd parity is used.
Answer: The bit in position 0010(2) is in error. Correct to 111111000.

7. Which odd-parity code is in error?


(a) 1011 (b) 1110 (c) 0101 (d) 1000
Answer: (c) 0101 has an error.

8. Which even-parity code is in error?


(a) 11000110 (b) 00101000 (c) 10101010 (d) 11111011
Answer: (d) 11111011 has an error.

9. Add an even parity bit to the end of each of the following codes.
(a) 1010100 (b) 0100000 (c) 1110111 (d) 1000110
Answer:
(a) 10101001 (b) 01000001
(c) 11101111 (d) 10001101

10. How many parity bits are required for data bits 11010 using the Ham-
ming code?
Answer: Four parity bits

11. Create the Hamming code for the data bits 0011 using even parity.
Answer: 1 0 0 0 0 1 1 (parity bits are bold)

12. Determine which of the following even parity codes are in error:
(a) 100110010 (b) 011101010 (c) 10111111010001010
Answer: (b) is incorrect.
2.12. ERROR DETECTION AND CORRECTION CODES 73

13. Attach the proper even parity bit to each of the following bytes of data:
(a) 10100100 (b) 00001001 (c) 11111110
Answer:
(a) 110100100 (b) 000001001 (c) 111111110

14. Determine the odd-parity Hamming code for the data bits 11001.
Answer: 001010001

15. Correct any error in each of the following Hamming codes with odd
parity.
(a) 110100011 (b) 100001101
Answer: (a) 110100010 (b) 100000101

2.12.3 Unsolved Problems

1. Determine which of the following odd parity codes are in error:


(a) 11110110 (b) 00110001 (c) 01010101010101010

2. Determine the even-parity Hamming code for the data bit 1100.

3. Correct any error in each of the following Hamming codes with even
parity.
(a) 1110100 (b) 1000111

You might also like