This is the mail archive of the gcc-help@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]
Other format: [Raw text]

RE: right shift : strange behavior


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


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