Description
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.Syntax
Parameters
Returns
Type: number (integer) The result of the bitwise XOR operation.Examples
Example 1: Basic XOR Operation
Example 2: Toggling Bits
Example 3: Simple Encryption/Decryption
Notes
- 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
See Also
- bitwise.and - Bitwise AND operation
- bitwise.or - Bitwise OR operation
- bitwise.not - Bitwise NOT operation
Frequently Asked Questions
What does flex.bitwise.xor return?
What does flex.bitwise.xor return?
It returns an integer where each bit is 1 only if the corresponding bits in the two operands differ. For example,
flex.bitwise.xor(5, 3) returns 6.What is XOR commonly used for?
What is XOR commonly used for?
XOR is useful for toggling flags, simple checksums, and detecting differences between two bitmasks.