Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In this example, the comparison operator operates on a signed int and an unsigned int. By the conversion rules, si is converted to an unsigned int. Because \—1 -1 cannot be represented as an unsigned int value, and unsigned int is treated modularly, the \—1 -1 is converted to UINT_MAX. This is in accordance with C99, Section 6.3.1.3, paragraph 2, which states:

Otherwise, if the new type is unsigned, the value is converted by repeatedly adding or subtracting one more than the maximum value that can be represented in the new type until the value is in the range of the new type.49)

Consequently, the program prints 0, because UINT_MAX is not less than 1.

...