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.? ---------- Prashant [ Jess added UBB [code] tags to preserve whitespace, check 'em out! ] [ January 08, 2003: Message edited by: Jessica Sant ]
There is no need to convert between hex to decimal, because the shift operations should be performed in a number system in which the bits are visualized, that is hex or binary. The variable to shift is already hex. int i1 = 0xffffffff; int i2 = i1 << 1; ffff fffe int i3 = i1 >> 1; ffff ffff int i4 = i1 >>> 1; 7fff ffff Please read Cat and Mouse games with bits to understand the bit operators in Java. This is from the Java Tutorial Shift and logical operators Also make sure to learn about hexadecimal, binary and octal number system. They are a bit basic thing for this forum.
Thank you Jose and Jessica. Prashant, I used Hex in that question because any other number system would have made the question more difficult. Hexadecimal was developed to make it easier to move data in and out of computers. Learning to use hexadecimal certainly makes a programers life easier. Hex is a programmers best friend.
Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>