What is the correct syntax to invert all the bits in a variable?
cachomachine Senior Member Aug 13, 2018 #1 What is the correct syntax to invert all the bits in a variable?
A AllyCat Senior Member Aug 13, 2018 #2 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.
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.
W westaust55 Moderator Aug 13, 2018 #3 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.
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.