In: Computer Science
Convert the following numbers as indicated. show steps. Use as
few digits in the results as necessary or as many as indicated in
the problems (note: don't use HEX table lookup).
a) (010010111)2
to Base 10
b) (-76)10 to
binary 2's complement representation using 9 bits
c) (67.4375)10
to unsigned binary
d) (-53)10 to
hexadecimal 2’s complement representation
a) Converting 010010111 to decimal 010010111 => 0x2^8+1x2^7+0x2^6+0x2^5+1x2^4+0x2^3+1x2^2+1x2^1+1x2^0 => 0x256+1x128+0x64+0x32+1x16+0x8+1x4+1x2+1x1 => 0+128+0+0+16+0+4+2+1 => 151 Answer: 151 b) -76 This is negative. so, follow these steps to convert this into a 2's complement binary Step 1: Divide 76 successively by 2 until the quotient is 0 > 76/2 = 38, remainder is 0 > 38/2 = 19, remainder is 0 > 19/2 = 9, remainder is 1 > 9/2 = 4, remainder is 1 > 4/2 = 2, remainder is 0 > 2/2 = 1, remainder is 0 > 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 1001100 So, 76 of decimal is 1001100 in binary So, 76 in normal binary is 001001100 Step 2: flip all the bits. Flip all 0's to 1 and all 1's to 0. 001001100 is flipped to 110110011 Step 3:. Add 1 to above result 110110011 + 1 = 110110100 so, -76 in 2's complement binary is 110110100 c) Converting 67.4375 to binary Convert decimal part first, then the fractional part > First convert 67 to binary Divide 67 successively by 2 until the quotient is 0 > 67/2 = 33, remainder is 1 > 33/2 = 16, remainder is 1 > 16/2 = 8, remainder is 0 > 8/2 = 4, remainder is 0 > 4/2 = 2, remainder is 0 > 2/2 = 1, remainder is 0 > 1/2 = 0, remainder is 1 Read remainders from the bottom to top as 1000011 So, 67 of decimal is 1000011 in binary > Now, Convert 0.43750000 to binary > Multiply 0.43750000 with 2. Since 0.87500000 is < 1. then add 0 to result > Multiply 0.87500000 with 2. Since 1.75000000 is >= 1. then add 1 to result > Multiply 0.75000000 with 2. Since 1.50000000 is >= 1. then add 1 to result > Multiply 0.50000000 with 2. Since 1.00000000 is >= 1. then add 1 to result > This is equal to 1, so, stop calculating 0.4375 of decimal is .0111 in binary so, 67.4375 in binary is 01000011.0111 d) -53 This is negative. so, follow these steps to convert this into a 2's complement binary Step 1: Divide 53 successively by 2 until the quotient is 0 > 53/2 = 26, remainder is 1 > 26/2 = 13, remainder is 0 > 13/2 = 6, remainder is 1 > 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 110101 So, 53 of decimal is 110101 in binary So, 53 in normal binary is 00110101 Step 2: flip all the bits. Flip all 0's to 1 and all 1's to 0. 00110101 is flipped to 11001010 Step 3:. Add 1 to above result 11001010 + 1 = 11001011 so, -53 in 2's complement binary is 11001011 Converting 11001011 to hexadecimal 1100 => C 1011 => B So, in hexadecimal 11001011 is 0xCB Answer: 0xCB