In SSMS, "SELECT ~ 0" gives -1 as the result. Similar results with other numbers too. I would like to know why.
Thanks!
In SSMS, "SELECT ~ 0" gives -1 as the result. Similar results with other numbers too. I would like to know why.
Thanks!
~
is Bitwise NOT
0
is 0x00000000
, ~0
is 0xFFFFFFFF
and since int
is signed, and negative numbers are stored using Two's complement
select cast(0xFFFFFFFF as int)
outputs
-1