ch05

advertisement

5.2

Chapter 5

Representing Numerical Data

5.1 a. (BL2) Since an octal integer represents 3 bits, a six-digit octal number will represent an 18 bit number.

Positive 18 bit binary numbers are represented by values from 0 to 011111111111111111.

Positive octal numbers range from 0 to 3777777. Since each group of three bits represent a single octal digit, there is an exact one-to-one relationship between these values. Similarly, negative values range from 111111111111111111 to 100000000000000000. Negative octal values range from 777777 to 400000. Again there is a direct correspondence between these values, therefore there is a one-to-one relationship for all possible numbers, and the equivalency is proven.

b, c.

(BL2-) The largest positive integer will be 377777

8

, or

131071 decimal. d. (BL2-) The largest negative number is 400000

8

, or -131072 decimal. a. (BL2-) The decimal number 1987 can be converted to binary form using either of the methods shown in Chapter 2. Using the “fit” method,

1987 = 1024 + 512 + 256 + 128 + 64 + 2 + 1

= 11111000011.

As a 16-bit number, the result is 0000011111000011. b. (BL2) The 2's complement of -1987 is found by inverting the previous result, and adding 1 to the inverted value:

1111100000111100 + 1 = 1111100000111101. c. (BL2-) The 4-digit hexadecimal equivalent of the answer in part (b) comes from dividing the binary value into hexadecimal parts, 4 bits at a time:

1111100000111101

2

= F83D

16

The six-digit number will thus be FFF846. An alternative way to see this: the student can convert the positive value in part b from 4-digit hex to 6-digit hex by adding two additional 0's at the left end of the number. Since each hex 0 complements to F, the two additional F's at the left end are apparent.

5.3 a. BL3) Since the value given begins with a 3, it represents a negative number in base 4.

Thus it is necessary to take the complement to find the magnitude.

The complement of 3333210

4

is 0000123 + 1 = 0000130. The same value can be achieved by subtracting 3333210 from 4444444.

b.

(BL2+) Since both numbers are positive, the magnitudes are the same as the original values

13220231 = 13220231

00120000 = 120000

carries

111

20000231 which has a negative value due to overflow.

The sign and magnitude of 20000231 can be found by taking its complement:

20000231 = -13333102 + 1 = -13333102

4

5.4

(BL2+) Converting 19575 to binary yields binary value 100110001110111.

Since the binary value requires 15 bits with the left-most digit a 1, it is not possible to represent the value in less than 16 bits. If the system doesn't check for overflow (some don't!) then it will perform the 2's complement to handle the minus sign.

This gives 011001110001001 = +13193 as a final value. Note that the answer and the original value sum to 32768, which is 2 15 . In other words, the answer has wrapped around as a result of the overflow. This is a situation one sees when the result of integer arithmetic operations exceed the integer size on systems that do not check for overflow.

5.5

(BL2)

2's complement

1111111111110000 a.

10000

1's complement

1111111111101111 b . 100111100001001 1011000011110110 c . 0100111000100100 1011000111011011

5.6 a. (BL2) 24379 = 24379

5098 = 5098

29477 = 29477

1011000011110111

1011000111011100 b. (BL2) 24379 = 24379

-5098 = 94902

119281 = 19281 c. (BL2) -24379 = 75621

5098 = 5098

80719 = -19281

5.7 (all BL2) a. 37968 = 37968

(-) 24109 = 975891

1013859 = 13859

b . 37968 = 37968 = 37968

(-) -70925 = (-) 929075 = 70925

108893 = 108893 c.

-10255 = 989745 = 989745

(-) -7586 = (-) 992414 = 7586

997331 = -2669

5.8 (all BL2) a .

1250 = 1250

772950 = -227050

774200 = -225800 b. 899211 = -100789

999998 = - 2

( 1)899209 = -100791 c.

970000 = -30000

30000 = 30000

( 1)000000 = 000000

5.9 (all BL2) a.

11001101101 = 1 + 4 + 8 + 32 + 64 + 512 + 1024 = 1645

111010111011 = 101000101 = - (1 + 4 + 64 + 256) = -325

(1)010100101000 = 8 + 32 + 256 + 1024 = 1320 b. 101011001100 = - 010100110100 = -1332

111111111100 = - 100 = - 4

(1)101011001000 = - 010100111000 = -1336

5.10 (BL3-) The largest positive four-digit 10's complement number is 4999, therefore the largest positive digit that can be added to 2468 is 4999 - 2468 = 2531.

5.11 (BL2+) In 12's complement base 12, the midpoint value is 6, therefore any number that starts with

6, 7, 8, 9, A, or B is negative, otherwise the number is positive.

5.12 (BL3) Overflow occurs when the result of an addition does not fit into the fixed number of bits available for the result. For a signed number, overflow occurs when the result flows into the sign bit. If the addition is performed unsigned , the sign bit has no significance, and any flow beyond the width of the number is a carry.

By definition, it is also an overflow, thus, they are one in the same.

5.13 (BL3)

.

-4 = 1111 1100

-6 = 1111 1010

(1)1110 (1)0110

The answer is obviously incorrect. The sign of the less significant four-bit nibble is different from both digits being added. The reason for the error is that overflow occurred in the less significant

nibble. To correct the error, it is necessary to perform unsigned addition on the less significant nibble, and to use the overflow as a carry into the more significant nibble:

-4 = 1111 1100

-6 = 1111 1010

(1)1110 (1)0110

Carry

——›

+ 1

1111 0110 = -10, which is now correct.

5.14 (BL2+) 4F09

16

+D3A5

(1)22AE

16

16

The result is positive, which is evident, since the most significant digit is in the 0-7 range.

Repeating the operation in binary,

4F09 = 0100111100001001

2

+D3A5 = 1101001110100101

2

(1)0010001010101110

2

= 22AE

16

5.15 a. (BL2) The exponent is 36

8

- 40

8

= - 2. Thus the number is - 6621

8 -2 = - 66.21

8 b. (BL2+) In decimal, the value is -54. (2/8 + 1/64) = -54 17/64 c.

(BL2-) Changing the exponent from 36 to 37 multiplies the magnitude of the value by 8.

5.16 a. (BL2+) Since the implied decimal point is at the beginning of the mantissa, the value must be represented as .19957

10 5 . With an exponent stored excess-40, the represemtation is

1451996. b. (BL2+) The range of numbers is



0.0001

10 -40 to .9999

10 59 . c. (BL2-) The only change is the sign: 7451996. d. (BL2) The six-digit 10's complementary representation of -19557 is 980443. e. (BL2) 0.0000019557 = .19557

10 -5 . The representation is 1351956.

5.17 a. (BL2) 123.57

1015 = 1.2357

1017. With exponent excess-49, the result is 0661236. b.

(BL2+) The smallest storable number is represented by 0000001 = 0.001

10 -49

5.18

a. (BL3) Excess-20 would be a good choice, since it is midway between 00 and 33. b. (BL3) 16.5 = 100.2

4

= .1002

4 3 . The representation is 0231002.

5.19 (all BL2) a.

110110.011011 = 1.10110011011

2 5 . The representation is

b

0 10000101 11011001101100000000000.

. -1.1111001 is represented as 1 10000000 11111001000000000000000 c . -4F7F

16

= -100111101111111 = -1.00111101111111

1 10001110 10011110111111100000000

2 14 . The representation is d. 0.00000000111111 = 1.11111

2 -9 . The representation is

0 01110111 11111100000000000000000 e. 0.1100

2 36 = 1.100

2 35 . The representation is

0 10100011 11000000000000000000000 f. 0.1100

2 -36 = 1.100

2 -37 . The representation is

0 01011011 11000000000000000000000

5.20

(all BL2+) a. C2F00000

16

= 1100001011110... . The exponent is 10000101, and the mantissa is 1.110.

Shifting the number 5 places for the excess-128 exponents produces 111000. The result in decimal is - 56.0. Alternatively, the number is -1 3/4

32 = - 56.0. b. 3C540000

16

= 0011110001011000... . The exponent is 01111000, and the mantissa is

1.0101. The mantissa must be shifted 8 places to the right, so the mantissa is 0.000000010101.

The decimal result, in fractional form is (1/256 + 1/1024 + 1/4096) = 21/4096.

5.21 (all BL3)

171.625

10

= 10101011.101

2

. The IEEE 754 format requires the number to be normalized as 1.0101011101

2 7 . Using 8 bit excess-127 notation for the exponent, and not storing the first digit of the mantissa gives the result

0 10000110 01010111010000000000000.

5.22 (BL1+) -129975 is represented as 0000 0001 0010 1001 1001 0111 0101 1101

5.23

(all BL2+) a. To add the numbers, the exponents must agree.

05225731 = 05225731

04833300 = 05200003

05225734 = 0.25734 X 10 2 = 25.734 b.

05012500 = 05300012

95325750 = 95325750

Subtracting, 95325738 = 0.25738 X 10 3 = 257.38

5.24 a. (BL2) Multiplying the mantissas, 0.525

0.222 = 0.116550.

The exponent is 54 + 48 - 50 = 52.The result is 05211655. b. (BL2) Multiplying the mantissas, 0.5

0.5 = 0.25. The exponent is 46 + 44 -50 =

40. The sign is positive. ((-)

(-) = (+)) The result is 04025000.

5.25 (BL3-) 3DEC00000 = 0 01111011 11011000...

C24C00000 = 1 10000100 10011000...

To add, the smaller exponent must be increased to match the larger; the mantissa is shifted right one space for each increment of the exponent. This gives

0 01111011 11011000 = 0 10000100 0000000001101100..

1 10000100 10011000 = 1 10000100 100110000000000..

Subtracting, 1 10000100 1001011110010100..

= -1.001011110010100 X 2

= -10010.11110010100

4 .

Multiplying the two mantissas, 1.1011000

1.0011000 = 10.00000001. Adding the exponents, and adjusting, the exponent becomes 01111011 + 10000100 - 10000000 = 01111111. However, it is necessary to renormalize the mantissa to 1.000000001

21, which adds 1 to the exponent. The final result is 1 10000000 10000000010...

5.26 (BL3)

This is a programming exercise.

5.27.

(BL1+) The student is adding in hexadecimal.

Download