previous | start | next

Overflow for the unsigned types

For unsigned integer types in C, adding two unsigned values x and
y, overflow occurred if the result is smaller than the operands

        x + y < x

or 

        x + y < y

This is another example of how integer arithmetic for these data types
is different from ordinary mathematical integer arithmetic. 

That is, the usual rules for < do not always hold for unsigned
short integers.

0 < 65000  and 0 < 536, but 

      65000 + 536 < 65000

and

      65000 + 536 < 536

since 65000 + 536 is 0 as unsigned short int type.


previous | start | next