News for hackers. Stuff that matters.
Re:My personal C coding style as of late 2023 by sokoloff on Tuesday October 10, 2023 @12:12AM (#37828435)
If b = 0x7fffffff and c = 0x7fffffff, b and c both fit in 31 bits, and b + c overflows to -2 in signed int32 twos-complement math (I think).

If b = 0x40000000 and c = 0x40000000, b and c both fit in 31 bits, and b + c overflows to -2147483648 in signed int32 twos-complement math (I think).

Maybe the definition of "32 bit integer type" you're using is meant to encompass only 32 bits as all unsigned (but then there are a - b terms that would overflow if b > a).

Or perhaps I've gotten something else wrong.

Re:My personal C coding style as of late 2023 by kazinator on Tuesday October 10, 2023 @12:39AM (#37828548)
[delayed]