Performs a bitwise XOR (exclusive OR) operation on two integers. Each bit in the result is 1 if the corresponding bits in the operands are different.
flex.bitwise.xor(a, b)| Parameter | Type | Required | Description |
|---|---|---|---|
a |
number (integer) | Yes | First operand |
b |
number (integer) | Yes | Second operand |
Type: number (integer)
The result of the bitwise XOR operation.
RETURN flex.bitwise.xor(12, 10) AS resultOutput:
result
------
6
(Binary: 1100 XOR 1010 = 0110 = 6)
WITH 5 AS value, 3 AS toggleMask
RETURN flex.bitwise.xor(value, toggleMask) AS toggledOutput:
toggled
-------
6
(Binary: 0101 XOR 0011 = 0110)
WITH 42 AS data, 17 AS key
WITH flex.bitwise.xor(data, key) AS encrypted
RETURN flex.bitwise.xor(encrypted, key) AS decryptedOutput:
decrypted
---------
42
(XOR with same key twice returns original value)
- Operates on 32-bit signed integers in JavaScript
- Both operands are converted to integers if needed
- XOR with same value twice returns the original value
- Commonly used for toggling flags and simple encryption
- bitwise.and - Bitwise AND operation
- bitwise.or - Bitwise OR operation
- bitwise.not - Bitwise NOT operation