This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: portable signed right shift
- To: aoliva at redhat dot com, nbecker at fred dot net
- Subject: Re: portable signed right shift
- From: dewar at gnat dot com
- Date: Tue, 27 Mar 2001 17:33:49 -0500 (EST)
- Cc: gcc at gcc dot gnu dot org
>((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 :-)