Inverting bits in a variable.

AllyCat

Senior Member
Hi,

Any of the following (and probably more variations) for either a byte or word variable:

Code:
b1 = not b1
b1 = b1 xor %11111111
b1 = b1 xor 255
b1 = b1 ^ $FF
Cheers, Alan.
 

westaust55

Moderator
Or if you have an X1 or X2 PICAXE part then use the invert command:
B1 = INV B1
B1 = ~ B1

Good to indicate which PICAXE is being used as that can determine the range of answers available.
 
Top