You beat me out - I had an almost identical reply ready when I saw yours. Let me just add that ~ tries to use an integer value even if only a floating-point value is set, and even if it is out of integer range (which can result in some strange results.)
Also, for any of the bitwise/stringwise ops (~, &, ^, |), quote the variable to force stringwise semanics if you are unsure where it has been:
$ perl -wle'$x="abc"; print ~$x; print $x+0; print ~$x; print ~"$x"'
Argument "abc" isn't numeric in addition (+) at -e line 1.