Skip to main content

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

Output:
(Binary: 1100 XOR 1010 = 0110 = 6)

Example 2: Toggling Bits

Output:
(Binary: 0101 XOR 0011 = 0110)

Example 3: Simple Encryption/Decryption

Output:
(XOR with same key twice returns original value)

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

Frequently Asked Questions

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.
XOR is useful for toggling flags, simple checksums, and detecting differences between two bitmasks.