0x80000000
in binary is
0b10000000000000000000000000000000
When you add two 0x80000000
s together,
|<- 32bits ->|
0b10000000000000000000000000000000
+ 0b10000000000000000000000000000000
------------------------------------
0b100000000000000000000000000000000
|<- 32bits ->|
However, int
on your machine seem to have 32 bits, so only the lower 32 bits are preserved, which means the 1
in your result is silently discarded. This is called an Integer Overflow.
Also note that in C, signed (as opposed to unsigned, i.e. unsigned int
) integer overflow is actually undefined behavior, which is why !(tmin + tmin)
gives 0x0
instead of 0x1
. See this blog post for an example where a variable is both true and false due to another undefined behavior, i.e. uninitialized variable.