Question about C behaviour for unsigned integer underflow

Posted by nn on Stack Overflow See other posts from Stack Overflow or by nn
Published on 2010-05-03T19:05:18Z Indexed on 2010/05/03 19:08 UTC
Read the original article Hit count: 334

Filed under:
|
|
|
|

I have read in many places that integer overflow is well-defined in C unlike the signed counterpart.

Is underflow the same?

For example:

unsigned int x = -1; // Does x == UINT_MAX?

Thanks.

I can't recall where, but i read somewhere that arithmetic on unsigned integral types is modular, so if that were the case then -1 == UINT_MAX mod (UINT_MAX+1).

© Stack Overflow or respective owner

Related posts about c

    Related posts about type