# XOR operation

Known Petr Mazanec ago

## Hi, I would like to use xor operator to switch between values 0 and 1 of the variable X (see e.g. https://xor.pw). Assume variable X equals 0. - STEP 1: X=X xor 1 so variable X will be 1 (because 0 xor 1 = 1) - STEP 2: Repeat X=X xor 1, so variable X will be 0 (because 1 xor 1 = 0) But it does not work... I have attached the sample file and the screenshot. BTW I can use ( X + 1) mod 2 to have the same result and it works, but I was just curious why I cannot use xor ? Thanks a lot Petr

Replies (2)

Hello, our XOR function is designed to be used at a higher language level, to be used comfortably with the rest of the functions we have. It can only work with values of true or false. False XOR False = False, True XOR False = True, True XOR True = False. To make a switch between 0 and 1 I recommend that you use the OnToggle event. I'll send you an example.

Regards.

Hello Ria Arias,

Understood. It could could be used as a logical, not bitwise operator as well as the other operators like NOT, etc.

Also thanks for OnToggle event example - I have not used this event yet.

Thanks a lot

Petr