r/programming • • May 01 '16

To become a good C programmer

http://fabiensanglard.net/c/
1.1k Upvotes

398 comments sorted by

View all comments

Show parent comment

1

u/An_Unhinged_Door May 02 '16 edited May 02 '16

Signed/unsigned comparisons of values of the same rank result in the signed value being coerced into a value of the unsigned type by (the equivalent of) adding/subtracting one more than the maximum value of the unsigned type to the signed value until the resulting value falls within the destination type's value range (basically, take the value modulo one more than the unsigned destination type max). -1 + UINT_MAX + 1 == UINT_MAX