In: Computer Science
convert -97 to 8-bit sign-magnitude, 1's complement, 2's complement and excess-127.
Please be careful and explain all the steps and details.
This is negative. so, follow these steps to convert this to various binary formats. Divide 97 successively by 2 until the quotient is 0 > 97/2 = 48, remainder is 1 > 48/2 = 24, remainder is 0 > 24/2 = 12, remainder is 0 > 12/2 = 6, remainder is 0 > 6/2 = 3, remainder is 0 > 3/2 = 1, remainder is 1 > 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 1100001 So, 97 of decimal is 1100001 in binary Adding 1 zeros on left hand side of this number to make this of length 8 So, 97 in normal binary format is 01100001 sign-magnitude: ----------------- set 1 as left most bit, since this number is negative. so, 01100001 becomes 11100001 ===================================== || sign-magnitude: 11100001 || ===================================== 1's complement: ----------------- flip all the bits. Flip all 0's to 1 and all 1's to 0. 01100001 is flipped to 10011110 ===================================== || 1's complement: 10011110 || ===================================== 2's complement: ----------------- Add 1 to above result 10011110 + 1 = 10011111 ===================================== || 2's complement: 10011111 || ===================================== for excess-127: --------------- for binary value add 127 to -97 127-97 = 30 Divide 30 successively by 2 until the quotient is 0 > 30/2 = 15, remainder is 0 > 15/2 = 7, remainder is 1 > 7/2 = 3, remainder is 1 > 3/2 = 1, remainder is 1 > 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 11110 So, 30 of decimal is 11110 in binary ================================= || excess-127: 00011110 || =================================