In PHP, if I run the following simple program
$number = 9;
var_dump( ~ $number );
my output is
int(-10)
This is confusing to me. I thought ~
was the bitwise NOT
operator. So I was expecting something like.
if binary 9 is 00000000000000000000000000001001
then Bitwise NOT 9 11111111111111111111111111110110
Meaning ~9
should come out as some ludicrously large integer like 4,294,967,286
.
What subtly of precedence, type coercion, or something else am I missing here?