The operator ~returns this result:
~N = -(N+1)
But this is the effect of inverting the value of all bits of the variable.
Double tide is ~~used to convert some types to int, since the operator ~converts the value to a 32-bit int before inverting its bits. Thus:
~~'-1' = -1
~~true = 1
~~false = 0
~~5.6 = 5
source
share