Re: Bitwise shift operator on 8-byte integers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux