This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
portable signed right shift
- To: gcc at gcc dot gnu dot org
- Subject: portable signed right shift
- From: nbecker at fred dot net
- Date: 27 Mar 2001 16:15:27 -0500
As the standard states:
3 The value of E1 >> E2 is E1 right-shifted E2 bit positions. If E1 has
an unsigned type or if E1 has a signed type and a nonnegative value,
the value of the result is the integral part of the quotient of E1
divided by the quantity 2 raised to the power E2. If E1 has a signed
type and a negative value, the resulting value is implementation-
defined.
OK, great. So what is an efficient, portable way to get a signed
right shift?