In: Computer Science
What decimal value does the 8-bit binary number 10011110 have if:
a) it is interpreted as an unsigned number?
b) It is on a computer using signed-magnitude representation?
c) It is on a computer using one’s complement representation?
d) It is on a computer using two’s complement representation?
a) => 10011110 => 1x2^7+0x2^6+0x2^5+1x2^4+1x2^3+1x2^2+1x2^1+0x2^0 => 1x128+0x64+0x32+1x16+1x8+1x4+1x2+0x1 => 128+0+0+16+8+4+2+0 => 158 Answer: 158 b) 10011110 since left most bit is 1, this number is negative number. convert 0011110 to decimal => 0011110 => 0x2^6+0x2^5+1x2^4+1x2^3+1x2^2+1x2^1+0x2^0 => 0x64+0x32+1x16+1x8+1x4+1x2+0x1 => 0+0+16+8+4+2+0 => 30 Answer: -30 c) since left most bit is 1, this number is negative number. so, follow these steps below to convert this into a decimal value. I. first flip all the bits. Flip all 0's to 1 and all 1's to 0. 10011110 is flipped to 01100001 01100001 in decimal => 01100001 => 0x2^7+1x2^6+1x2^5+0x2^4+0x2^3+0x2^2+0x2^1+1x2^0 => 0x128+1x64+1x32+0x16+0x8+0x4+0x2+1x1 => 0+64+32+0+0+0+0+1 => 97 Answer: -97 d) II. Add 1 to 1's complement binary 01100001 + 1 = 01100010 III. Now convert this result to decimal value => 1100010 => 1x2^6+1x2^5+0x2^4+0x2^3+0x2^2+1x2^1+0x2^0 => 1x64+1x32+0x16+0x8+0x4+1x2+0x1 => 64+32+0+0+0+2+0 => 98 Answer: -98