I would like to flip all the bits in a byte. How would I do that?
Ex:
input: 10101000
output: 01010111
I would like to flip all the bits in a byte. How would I do that?
Ex:
input: 10101000
output: 01010111
Use the ~ bitwise complement operator.
byte flipped = (byte) ~original;