Originally posted by Prashant Neginahal:
Please help me how to solve this question.I have difficulty in converting hex form to decimal and then do shift opeartion.Is it not time consuming.?
Actually -- don't you need to go from hex to binary? shift it -- then back to hex?
Converting Hex to Binary is actually quite easy -- each hex digit goes to a 4 digit binary number:
i1 = 0xffffffff =
1111 1111 1111 1111 1111 1111 1111 1111
i2 = i1 << 1;
1111 1111 1111 1111 1111 1111 1111 1110
= 0xfffffffe
i3 = i1 >> 1;
1111 1111 1111 1111 1111 1111 1111 1111
= 0xffffffff
i4 = i1 >>> 1;
0111 1111 1111 1111 1111 1111 1111 1111
= 0x7fffffff