The reason is because true
is equivalent to 1
, and when you perform a bitwise NOT (~
) on the number 1
you get -2
. Which when combined with the NOT operator (!
) will produce false (because the only number that will produce true when combined with the NOT operator is 0
)
Here is some information that you might find interesting
Quoted from the link:
Bitwise NOTing any number x yields -(x + 1)