Introduction to Computer Science (Fourth Edition) -- Exercises Answers [Behruz Frozan]

third chapter

review questions

Q3-1 Name 5 types of data that computers can process.

        A: Number, text, audio, image, video

Q3-2 How does the length of a bit pattern relate to the number of symbols it can represent?

        A: The number of symbols represented = 2^n, n represents the length of the bit pattern

Q3-3 How does the bitmap method represent an image with a bit pattern?

        A: Bitmap (raster image), each pixel is represented by a bit pattern

Q3-4 What are the advantages of the vector graphics method over the bitmap method? What are its disadvantages?

        A: Disadvantages: Not suitable for storing the subtleties of photo images

           Advantages: After zooming in on the image, the image will not become blurred and rough

Q3-5 What steps are required to convert audio data into a bit pattern?

        A: 1. Sampling 2. Quantization 3. Encoding

Q3-6 Compare and contrast the representations of positive integers in unsigned, signed-plus-absolute, and two's complement formats.

        A: Unsigned integer: convert the integer into a binary number, if the number of binary digits is less than n bits, add 0 to the left;

           Sign plus absolute value: Same as above, the leftmost bit is the sign bit

           Two's complement format: Same as above, the leftmost bit is the sign bit

Q3-7 Compare and contrast the representation of negative integers in unsigned, signed-plus-absolute, and two's complement formats.

        A: Negative integers do not exist in unsigned integer representation;

           In the sign plus absolute value representation, the leftmost digit of a negative integer is 1, and the rest of the digits use unsigned representation

           In two's complement format, take the absolute value of a negative integer, bitwise invert and +1

Q3-8 Compare and contrast the representation of 0 in sign plus absolute value, two's complement format, and remainder format.

        A: Sign plus absolute value method: +0 means 0000 0000; -0 means 1000 0000

           In two's complement format: 0 means 0000 0000

           In the remainder code format: 2^(m-1) (m represents the size of the storage index of the memory unit)

Q3-9 discusses the role of the leftmost bit in sign-plus-absolute and two's complement formats.

        A: The leftmost is the sign bit, 0 means a positive number, 1 means a negative number

Q3-10 Answer the following questions about floating-point representation of real numbers:

           a. Why is normalization needed?

                A: In order to unify the fixed part of the notation

           b. What is the mantissa?

                A: Refers to the binary number to the right of the decimal point, stored as an unsigned integer

           c. After the numbers are normalized, what information is stored in memory by the computer?

                A: sign bit size, exponent size, mantissa size

practice questions

P3-1 2*2*2*2*2 = 32 types

P3-2 10*10 = 100 types; 9*9 = 81 types;

P3-3 13*13*13*13*13 types; 12*12*12*12*12 types

P3-4 requires at least 3 digits

P3-5 requires at least 3 digits

P3-6 2^10 = 1024; 2^9 = 512; 2^11 = 2048; 900 employees need at least 10, can be allocated 1024 kinds of bit patterns, and then hire 300, need to increase to 11.

P3-7 2^4 = 16; a total of 6 bit patterns are wasted.

P3-8        256 = 2^8,8000*8 = 64000 bits

P3-9        a. 23 = (0001 0111)2

                b. 121 = (0111 1001)2

                c. 34 = (0010 0010)2

                d. 342 -- Overflow

P3-10        a. 41 =  (0000 0000 0010 1001)2

                  b. 411 = (0000 0001 1001 1011)2

                  c. 1234 = (0000 0100 1101 0010)2

                  d. 342 = (0000 0001 0101 0110)2

P3-11        a. -12 = (1111 0100)2

                 b. -145 -- overflow

                 c. 56 = (0011 1000)2

                 d. 142 -- Overflow

P3-12        a. 102 = (0000 0000 0110 0110)2

                  b. -179 = (1111 1111 0100 1101)2

                  c. 534 = (0000 0010 0001 0110)2

                  d. 62056 -- Overflow

P3-13        a. (0110 1011)2 = 107

                  b. (1001 0100)2 = 148

                  c.(0000 0110)2 = 6

                  d.(0101 0000)2 = 80

P3-14        a. (0111 0111)2 = 119

                  b. (1111 1100)2 = -4

                  c. (0111 0100)2 = 116

                  d. (1100 1110)2 = -50

P3-15 a. (0111 0111)2 = 119 Convert to a negative number: Negative +1 (1000 1001)2 = -119

                  b. (1111 1100)2 = -4 Convert to a positive number: Negate +1 (0000 0100)2 = 4

                  c. (0111 0111)2 = 119 is converted to a negative number: Negative +1 (1000 1001)2 = -119

                  d. (1100 1110)2 = -50 is converted to a positive number: Negate +1 (0011 0010)2 = 50

P3-16        a.(0111 0111)2 = 119 ~ (1000 1001)2 = -119 ~ (0111 0111)2 = 119

                  b.(1111 1100)2 = -4 ~ (0000 0100)2 = 4 ~ (1111 1100)2 = -4

                  c.(0111 0100)2 = 116 ~ (1000 1100)2 = -116 ~ (0111 0100)2 = 116

                  d.(1100 1110)2 = -50 ~ (0011 0010)2 = 50 ~ (1100 1110)2 = -50

P3-17 a. 1.10001 normalized (1.10001)2 * 2^0 exponent is 0    

                  b.2^3*111.1111 normalized (1.111111)2 * 2^5 exponent is 5

                  c.2^-2*101.110011 normalized (1.01110011)2 * 2^0 exponent is 0

                  d.2^-5*101101.00000110011000 normalized (1.0110100000110011000)2 * 2^0 exponent is 0

P3-18        a.-2^0 * 1.10001 = 1011 1111 1100 0100 0000 0000 0000 0000

                  b.+2^3 * 1.111111 = 0100 0001 0111 1110 0000 0000 0000 0000

                  c.+2^-4 * 1.01110011 = 0011 1101 1011 1001 1000 0000 0000 0000

                  d.-2^-5 * 1.01101000 = 1011 1101 0011 0100 0000 0000 0000 0000

P3-19        a.-2^0 * 1.10001=1000 0111 1111 1000 1000 0000 0000 0000 0000 0000 0000 0000                         0000 0000 0000 0000

                  b.+2^3 * 1.111111=0000 1000 0010 1111 1100 0000 0000 0000 0000 0000 0000 0000                       0000 0000 0000 0000

                  c.+2^-4 * 1.01110011=0000 0111 1011 0111 0011 0000 0000 0000 0000 0000 0000                           0000 0000 0000 0000 0000

                  d.-2^-5 * 1.01101000= 1000 0111 1010 0110 1000 0000 0000 0000 0000 0000 0000                         0000 0000 0000 0000 0000 

P3-20        a.7.1875 = 0100 0000 1110 0110 0000 0000 0000 0000 

                  b. -12.640625 = 1100 0001 0100 1010 0100 0000 0000 0000

                  c.11.40625 = 0100 0001 0011 0110 1000 0000 0000 0000

                  d.-0.375 = 1011 1110 1100 0000 0000 0000 0000 0000

P3-21        a. (0111 0111)2 = 119

                  b. (1111 1100)2 = -124

                  c. (0111 0100)2 = 116

                  d. (1100 1110)2 = -75

P3-22        a. 53 = (0011 0101)2

                  b. -107 = (1110 1011)2

                  c. -5 = (1000 0101)2

                  d. 154 -- Overflow

P3-23        a. 53 = 0011 0101

                  b. -107 = 1001 0100

                  c. -5 = 1111 1010

                  d. 154 -- Overflow

P3-24 a. (0111 0111)2 = 119 (positive number's complement is equal to itself)

                  b. (1111 1100)2 = -3 (the one's complement of a negative number is equal to the bitwise inversion of the absolute value)

                  c. (0111 0100)2 = 116

                  d. (1100 1110)2 = -49

P3-25        a.(0111 0111)2 = 119 ~ (1000 1000)2 = -119 ~ (0111 0111)2 = 119

                  b.(1111 1100)2 = -3 ~ (0000 0011)2 = 3 ~ (1111 1100)2 = -3

                  c.(0111 0100)2 = 116 ~ (1000 1011)2 = -116 ~ (0111 0100)2 = 116

                  d.(1100 1110)2 = -49 ~ (0011 0001)2 =49 ~ (1100 1110)2 = -49

P3-26 a. (0111 0111)2 Inversion (1000 1000)2 +1 (1000 1001)

                  b. (1111 1100)2 inversion (0000 0011)2 +1 (0000 0100)

                  c.(0111 0100)2 negates (1000 1011)2 +1 (1000 1100)

                  d.(1100 1110)2 inversion (0011 0001)2 +1 (0011 0010)

P3-27        a.  -499 ~ +499

                  b. When the leftmost digit is 0~4, it means a positive number; when it is 5~9, it means a negative number

                  c. There will be two 0s

                  d. +0 = 000;-0 = 999

P3-28 a. 234 b. overflow c. 874 d. 888

P3-29        a. -500 ~ +499

                  b. When the leftmost digit is 0~4, it means a positive number; when it is 5~9, it means a negative number

                  c. There will not be two 0s

                  d. Only one 0

P3-30 a. 234 b. overflow c. 875 d. 889

P3-31        a. -2047 ~ +2047

                  b. The inverse code of a positive number is equal to itself, and the inverse code of a negative number is equal to FZ (Z means that a negative number corresponds to a number)

                  c. There will be two 0s

                  d. +0 = 000;-0 = FFF

P3-32 a. Overflow b. Overflow c. FE5 d. E1D

P3-33        a. -2048 ~ +2047

                  b. The complement of a positive number is equal to itself, and the complement of a negative number is equal to its complement + 1

                  c. will not

                  d. Only one 0

P3-34 a. Overflow b. Overflow c. FE6 d. E1E

Guess you like

Origin blog.csdn.net/yxyyy12345/article/details/131352647