Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to computers 103 學年度 上學期 Solution of Homework_ch12 授課教授:李錫智.

Similar presentations


Presentation on theme: "Introduction to computers 103 學年度 上學期 Solution of Homework_ch12 授課教授:李錫智."— Presentation transcript:

1 Introduction to computers 103 學年度 上學期 Solution of Homework_ch12 授課教授:李錫智

2 Question 1 Please convert these units as shown below.(8 bits) Binary -> Decimal (00110110) 2 = ( ) 10 (11001101) 2 = ( ) 10 Decimal -> Binary (16) 10 = ( ) 2 (106) 10 = ( ) 2 (255) 10 = ( ) 2

3 Solution Q1-1 00110110 1*2 1 + 1*2 2 + 1*2 4 + 1*2 5 = 54 11001101 1*2 0 + 1*2 2 + 1*2 3 + 1*2 6 + 1*2 7 = 109

4 Solution Q1-2 16 / 2 = 8…0=>( 00010000 ) 2 8 / 2 = 4…0 4 / 2 = 2…0 2 / 2 = 1…0 1 / 2 = 0…1 106 / 2 = 53…0=>( 01101010 ) 2 53 / 2 = 26…1 26 / 2 = 13…0 13/ 2 = 6…1 6 / 2 = 3…0 3 / 2 = 1…1 1 / 2 = 0…1

5 Solution Q1-3 255 / 2 = 127…1=>( 11111111 ) 2 127 / 2 = 63…1 63 / 2 = 31…1 31 / 2 = 15…1 15 / 2 = 7…1 7 / 2 = 3…1 3 / 2 = 1…1 1 / 2 = 0…1

6 Question 2 Unsigned integer can be just only represented to positive numbers, if you want to represent to negative number, you can use 2’s complement notation. (8 bits) Please convert these units as shown below in 2’s complement. Binary -> Decimal (00110110) 2 = ( ) 10 (11001101) 2 = ( ) 10 Decimal -> Binary (-5) 10 = ( ) 2 (-128) 10 = ( ) 2 (127) 10 = ( ) 2

7 Solution Q2-1 00110110=>sign: Positive 1*2 1 + 1*2 2 + 1*2 4 + 1*2 5 = 54 11001101=>sign: Negative ==invert==>>00110010 + 1 (-1) * ( 1*2 1 + 1*2 4 + 1*2 5 + 1 )= -51

8 Solution Q2-2 -5 == sign + invert(5-1) == sign + invert(4) 11111011 -128 == sign + invert(128-1) == sign + invert(127) 10000000 127 = 01111111

9 Question 3 Strings can be represented as sequences of ASCII codes. How would the string “EE107” be represented? What string would be represented by bit pattern “01000111011011110110000101101100”?

10 Solution Q3-1 ‘E’ = 01000101 ‘1’ = 00110001 ‘0’ = 00110000 ‘7’ = 00110111 ANS :0100010101000101001100010011000000110111

11 Solution Q3-2 01000111011011110110000101101100 ANS : Goal

12 Question 4 What the value would be represented by the bit pattern 01000111011011110110000101101100 with IEEE single-precision floating point? (Format is represented by (-1) s * 2 k * 1.yyyy…)

13 Solution Q4 01000111011011110110000101101100 10001110 = 142 (-1) 0 * 2 142-127 * (1.11011110110000101101100) 2 = (1.11011110110000101101100) 2 * 2 15 (1110111101100001.01101100) 2 = (61281.421875) 10

14 The end of Solution Homework_ch12 Teacher assistant: zlhe@water.ee.nsysu.edu.tw


Download ppt "Introduction to computers 103 學年度 上學期 Solution of Homework_ch12 授課教授:李錫智."

Similar presentations


Ads by Google