how does 11111111111111111111111111111110 evaluate to 2?

I was testing out the bitwise not operator in Java. I printed out the result of ~1 in binary, and it returned "11111111111111111111111111111110" which apparently evaluates to -2. I know that you have to add 1 to this to get -1 and that the leftmost bit just shows whether the number is positive or negative, but what I don't understand is why a binary number that large and with that many 1s evaluates to just -2. Help!...

Read More »

By: StackOverFlow - 5 days ago

Related Posts