Occasionally it is necessary to invert the bits for a number. Most often, this is part of custom algorithms or checksum calculations. It raises the general question: what’s the easiest way to do this?
“Bit-Flipping” can be done with the -bnot operator like this:
$number = 76
$newnumber = -bnot $number
The result shows one caveat, though…