Hacker News new | past | comments | ask | show | jobs | submit login

This is of course a joke. Here is why it holds in general. If x is signed number in two's complement representation then

    x + ~x = -1
because x has a 1 where ~x has a 0 and vice versa and because all ones 11...111 in two's complement always represents -1 [ * ].

Transformation of the last formula yields

    x + 1 = -~x
The other "tadpole" operator can be derived from the above one by setting x = -y

    -y + 1 = -~-y
    y - 1 = ~-y
[ * ] This follows from the fact that the sum of all powers of two from 0th to (n-1)th is equal to 2^n - 1. Now, if the sign of the most significant bit in all-ones binary number 11..111 is flipped then the sum becomes -1.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: