Bitwise shift operator on 8-byte integers
Eljay Love-Jensen
eljay@adobe.com
Wed Oct 6 11:47:00 GMT 2004
Hi Ankit,
>it still diplays -1. i could not understand why on right shift the sign
bit is not changed to 0 whats happening here?
You are right shifting a signed number. In a 2's complement machine, the
MSb is used to indicate a negative number; and will be replicated on right
shift.
For details on this kind of magic bit twiddling, get the fantastic book
Hacker's Delight by Henry S. Warren, Jr.
HTH,
--Eljay
More information about the Gcc-help
mailing list