This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: portable signed right shift


>((unsigned)foo >> M) ^ (1 << (N - 1)) - (1 << (N - 1))


Note that this gives target dependent results, but if you know you
are on a twos complement machine with the standard representation
of signed and unsigned, then you know the result (note that on such
machines this is likely what the shift operator does anyway :-)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]