This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: portable signed right shift
On Wed, Mar 28, 2001 at 01:08:49PM -0800, Geoff Keating wrote:
> Note that even on non-twos-complement machines, casting an int to an
> unsigned is required to behave the same way, that is (unsigned)-1 is
> always the largest possible unsigned value.
Yes, but after the bit manipulations you can't cast that back to
a signed int without overflowing. Eg. if you twos-complement
arithmetic right shift a -1, you'll get a ones-complement min-int.
r~