Gonna give a shot to my own question here.
Yes this is a 32-bit / 64-bit difference.
In 32-bit systems, a float type has to take up two memory spaces to get the required 64 bits. Php uses double-precision (see http://en.wikipedia.org/wiki/Floating_point#IEEE_754:_floating_point_in_modern_computers)
The $hex evaluates to a float type. Intval and decbin functions convert this into an int type (1st example above)
In the 2nd example we are using the not bitwise operator BEFORE we use decbin. This flips the bits in the two-memory space double-precision float first, and then is converted to int second. Giving us something different than what we expected.
Indeed, if we put the negate inside of the intval() like so:
$hex = 0x80008000;
print_r(decbin(intval(~$hex)) . '<br/>');
print_r(decbin(~$hex));
We get
1111111111111111111111111111111
1111111111111111111111111111111
As output.
I'm not good enough to prove this with math yet (which can be figured out with the help of this article http://en.wikipedia.org/wiki/Double_precision). But maybe when I have time later -_-
I think it's very important to learn how numbers are represented in computers so we can understand anomalies like this and not call them bugs.
print_r(~$hex)
andprint_r(~intval($hex))
? – Missis