+ 1

# Why is it that (-1 == ~!-1) is true?

How can (-1 == ~!-1) be true? I understand that !-1 equals 0, but what else is going on here?

1 Answer

+ 5

!-1 is false or 0. ~0 flips all the zero bits to one or -1.

+ 1

How can (-1 == ~!-1) be true? I understand that !-1 equals 0, but what else is going on here?

1 Answer

+ 5

!-1 is false or 0. ~0 flips all the zero bits to one or -1.