Introduction to Computer Science_HW1_solution
Introduction to Computer Science_HW1_solution
Homework_1
1 What is the function of the ALU subsystem in a computer?(ch.1)
The arithmetic/logic unit (ALU) is where calculations and logical operations take place.
2 A programming language has ten different instructions.
How many five-instruction programs can be written in thes language? 105=100,000
How many seven-instruction programs?(ch.1) 107=10,000,000
3 Convert the following hexadecimal numbers to decimal without using a calculator, showing your
work.(ch.2)
a (AB2)16 =2738
b (123)16 =291
c (ABB)16 =2747
d (35E.E1)16 =862.87890625 ≈ 862.879
4 Convert the following decimal numbers to binary.(ch.2)
a 1234 =(10011010010)2
b 88 =(1011000)2
c 124.02 ≈ (1111100.00000101)2
d 14.56 ≈ (1110.100011)2
5 Convert the following binary numbers to hexadecimal.(ch.2)
a (01101)2 =(0D)16
b (1011000)2 =(58)16
c (011110.01)2 =(1E.4)16
d (111111.111)2 =(3F.E)16
6 Change the following decimal numbers into binary using the alternative method discussed in Example
2.18.(ch.2)
a 3 5/8 =(0011.1010000)2
b 12 3/32 =(1100.0001100)2
c 4 13/64 =(0100.0011010)2
d 12 5/128 =(1100.0000101)2
7 Find the minimum number of digits needed in the destination system for each of the following
cases.(ch.2)
a Five-digit decimal number converted to binary. ⎡ log2105⎤ = ⎡16.6⎤ = 17
b Four-digit decimal number converted to octal. ⎡ log8104⎤ = ⎡4.4⎤ = 5
c Seven-digit decimal number converted to hexadecimal. ⎡ log16107⎤ = ⎡5.8⎤ = 6
8 Find the maximum value of an integer in each of the following cases.(b is base, k is number of
bits)(ch.2)
a b=10, k=10 1010-1=9999999999
b b=2, k=12 212-1=4095
c b=8, k=8 88-1=16,777,215
d b=16, k=7 167-1=268,435,455
9 Change the following decimal numbers to 8-bit two’s complement integers.(ch.3)
a -12 =11110100
b -145 overflow occurs
c 56 =00111000
d 142 overflow occurs
10 Change the following 8-bit unsigned numbers to decimal.(ch.3)
a 01101011 =107
b 10010100 =148
c 00000110 =6
d 01010000 =80
11 The following are two’s complement binary numbers. Show how to change the sign of the
number.(ch.3) (抱歉!助教抄題的時候 a 和 c 小題抄錯了,導致相同的題目。)
a 01110111 →10001001
b 11111100 →00000100
c 01110111 →10001001
d 11001110 →00110010
12 Normalize the following binary floating point numbers. Explicitly show the value of the exponent after
normalization.(ch.3) (抱歉!助教抄題的時候 c 和 d 小題抄錯了,導致沒有變化。)
a 1.10001 =20 x 1.10001
b 23 x 111.1111 =25 x 1.111111
c 2-4 x 1.01110011 =2-4 x 1.01110011
d -2-5 x 1.01101000 =-2-5 x 1.01101000
13 One method of representing signed numbers in a computer is one’s complement representation. In
this representation, to represent a positive number, we store the binary number. To represent a
negative number, we apply the one’s complement operation to the number. Store the following
decimal integers to one’s complement with 8-bit allocation.(ch.3)
a 53 =00110101
b -107 =10010100
c -5 =11111010
d 154 overflow occurs