This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: right shift : strange behavior
- From: "John (Eljay) Love-Jensen" <eljay at adobe dot com>
- To: "Manish Baphna" <manish_baphna at yahoo dot com>, <gcc-help at gcc dot gnu dot org>
- Date: Fri, 27 Jul 2007 04:50:57 -0700
- Subject: RE: right shift : strange behavior
- References: <514500.24300.qm@web38907.mail.mud.yahoo.com>
Hi Manish,
Because of C promotion rules, you are probably seeing this on your platform (other platforms may have different behavior, depending on the bit-sizes of long and int):
0x0 is taken to be a signed int.
0xFFFFFFFF is taken to be an unsigned int.
If you want 0xFFFFFFFF to be treated as a signed int, do this:
((signed int)0xFFFFFFFF)
If you want 0x0 to be treated as an unsigned int, do one of these;
0x0U
((unsigned int)0x0)
HTH,
--Eljay