Sun Studio 12: C User's Guide

6.4.7 Third Example: Integral Constants

In the following code, assume ints are 16 bits.

int f(void)
    int i = 0;

    return i > 0xffff;

Because the hexadecimal constant’s type is either int (with a value of– 1 on a two’s-complement machine) or an unsigned int (with a value of 65535), the comparison is true in– Xs and -Xt modes, and false in– Xa and– Xc modes.

Again, an appropriate cast clarifies the code and suppresses a warning:

-Xt, -Xs modes:
    i > (int)0xffff

-Xa, -Xc modes:
    i > (unsigned int)0xffff
    i > 0xffffU

The U suffix character is a new feature of ISO C and probably produces an error message with older compilers.