Introduction to computers 103 學年度 上學期 Solution of Homework_ch12 授課教授:李錫智
Question 1 Please convert these units as shown below.(8 bits) Binary -> Decimal ( ) 2 = ( ) 10 ( ) 2 = ( ) 10 Decimal -> Binary (16) 10 = ( ) 2 (106) 10 = ( ) 2 (255) 10 = ( ) 2
Solution Q * * * *2 5 = * * * * *2 7 = 109
Solution Q / 2 = 8…0=>( ) 2 8 / 2 = 4…0 4 / 2 = 2…0 2 / 2 = 1…0 1 / 2 = 0…1 106 / 2 = 53…0=>( ) 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
Solution Q / 2 = 127…1=>( ) / 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
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 ( ) 2 = ( ) 10 ( ) 2 = ( ) 10 Decimal -> Binary (-5) 10 = ( ) 2 (-128) 10 = ( ) 2 (127) 10 = ( ) 2
Solution Q =>sign: Positive 1* * * *2 5 = =>sign: Negative ==invert==>> (-1) * ( 1* * * )= -51
Solution Q == sign + invert(5-1) == sign + invert(4) == sign + invert(128-1) == sign + invert(127) =
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 “ ”?
Solution Q3-1 ‘E’ = ‘1’ = ‘0’ = ‘7’ = ANS :
Solution Q ANS : Goal
Question 4 What the value would be represented by the bit pattern with IEEE single-precision floating point? (Format is represented by (-1) s * 2 k * 1.yyyy…)
Solution Q = 142 (-1) 0 * * ( ) 2 = ( ) 2 * 2 15 ( ) 2 = ( ) 10
The end of Solution Homework_ch12 Teacher assistant: