Question about C behaviour for unsigned integer underflow

§6.2.5, paragraph 9:

A computation involving unsigned
operands can never overflow, because a
result that cannot be represented by
the resulting unsigned integer type is
reduced modulo the number that is one
greater than the largest value that
can be represented by the resulting
type.

Edit:

Sorry, wrong reference, but the result is still pinned down. The correct reference is §6.3.1.3 (signed and unsigned integer conversion):

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.

So yes, x == UINT_MAX.

Leave a Comment