Given this code snippet, is the output CPU dependent or not?

c

Solution

From C99 6.3.1.8 :

[...] Otherwise, if the operand that has unsigned integer type has rank greater or equal to the rank of the type of the other operand, then the operand with signed integer type is converted to the type of the operand with unsigned integer type.

Because `int` and `unsigned int` have the same conversion rank (see 6.3.1.1), -1 will be converted to `unsigned int`. As per 6.3.1.3, the conversion result will be `(-1 + UINT_MAX + 1) % (UINT_MAX + 1)` (arithmetically spoken) which is obviously `UINT_MAX` and thus greater than `0`.

The conclusion is that the C standard demands `(-1 > 0U)` to be true.

Problem

``` void main() { if(-1 > 0U) printf("True\n"); else printf("False\n"); } ``` Is it processor-dependent (big endian/little endian)?

Original source