In: Computer Science
I need clear explanation on how we got that answers. Thanks.
1. What is the decimal value for the 8 bit 2's complement number 0x36 arithmetic shift right by 3.
--> Ans is 6
2. What is the decimal value for the 8 bit 2's complement number 0x36 rotated left by 3
--> Ans is -79
Hexadecimal Binary 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000 9 1001 A 1010 B 1011 C 1100 D 1101 E 1110 F 1111 Use this table to convert from hexadecimal to binary Converting 36 to binary 3 => 0011 6 => 0110 So, in binary 36 is 00110110 1) 00110110 shifted right by 3 gives 00000110 since left most bit is 0, this number is positive so, we can directly convert this into a decimal value Converting 110 to decimal 110 => 1x2^2+1x2^1+0x2^0 => 1x4+1x2+0x1 => 4+2+0 => 6 Answer: 6 2) 00110110 shifted left by 3 gives 10110001 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. 10110001 is flipped to 01001110 II. Add 1 to above result 01001110 + 1 = 01001111 III. Now convert this result to decimal value Converting 1001111 to decimal 1001111 => 1x2^6+0x2^5+0x2^4+1x2^3+1x2^2+1x2^1+1x2^0 => 1x64+0x32+0x16+1x8+1x4+1x2+1x1 => 64+0+0+8+4+2+1 => 79 Answer: -79