In: Computer Science
1. Complete the following table using 8-bit representation ((show your work to get credit)
Decimal |
Signed Magnitude |
One’s Complement |
Two’s Complement |
30 |
|||
-47 |
|||
0 |
Question 1: Number is 30 Write down the decimal number and continually divide by 2 to give a result and a remainder. The remainder is either a 1 or a 0. 30 / 2 result 15 remainder 0 15 / 2 result 7 remainder 1 7 / 2 result 3 remainder 1 3 / 2 result 1 remainder 1 1 / 2 result 0 remainder 1 Read the remainders from bottom to top. ( 30 )10 = ( 11110 )2 prepend zeros to make it 8-bit ( 30 )10 = ( 00011110 )2 As it is positive number all Signed Magnitude, One’s Complement, Two’s Complement are same as 00011110 ==================================== Question 2: Number is -47 Write down the decimal number and continually divide by 2 to give a result and a remainder. The remainder is either a 1 or a 0. 47 / 2 result 23 remainder 1 23 / 2 result 11 remainder 1 11 / 2 result 5 remainder 1 5 / 2 result 2 remainder 1 2 / 2 result 1 remainder 0 1 / 2 result 0 remainder 1 Read the remainders from bottom to top. ( 47 )10 = ( 101111 )2 prepend zeros to make it 8-bit ( 47 )10 = ( 00101111 )2 -47 in Signed Magnitude = Replace most significant bit to 1 = 10101111 -47 in One’s Complement = Invert bits in binary = 11010000 -47 in Two’s Complement = Ones complement + 1 = 11010001 ==================================== Question 3: Number is 0 0 in 8-bit binary is 00000000 All Signed Magnitude, One’s Complement, Two’s Complement are same as 00000000
Decimal |
Signed Magnitude |
One’s Complement |
Two’s Complement |
30 |
00011110 |
00011110 |
00011110 |
-47 |
10101111 |
11010000 |
1101000 |
0 |
00000000 |
00000000 |
00000000 |