Reputation: 610
Can someone explain to me how
printf("%d", -2<2u?1:-1);
prints out '-1'. I assume there is some kind of implicit conversion going on but I can't seem to grasp it.
Upvotes: 5
Views: 161
Reputation: 9619
-2
is getting converted to unsigned integer
. This will be equal to UINT_MAX - 1
, which is definitely greater than 2
. Hence, the condition fails and -1
is printed.
Upvotes: 5