Engineering

BITXOR Formula

Returns the bitwise exclusive OR (XOR) of two non-negative integers. Each bit in the result is 1 if the corresponding bits in the two inputs differ. BITXOR is used for toggle operations, simple encryption, error detection (checksums), and finding differences between binary values.

Syntax

BITXOR(number1, number2)
ParameterDescription
number1 Parameter of the BITXOR function.
number2 Parameter of the BITXOR function.
Try BITXOR in Viztab — free, no signup

Examples

Basic XOR operation

Formula
=BITXOR(5, 3)
6. In binary: 101 XOR 011 = 110, which is 6 in decimal. Bits that differ between the two numbers are set to 1.

Toggle a flag

Formula
=BITXOR(7, 2)
5. In binary: 111 XOR 010 = 101. Flips bit 1 (the middle bit), turning off write permission from 'rwx' (7) to get 'r-x' (5).

Simple checksum

Formula
=BITXOR(BITXOR(65, 66), 67)
64. XOR-ing multiple values together produces a simple checksum. If any value changes, the checksum changes.

Common Errors

#NUM!

One or both numbers is negative, or exceeds 2^48 - 1.

#VALUE!

A non-numeric argument was provided.

Tips

Toggle bits on/off

XOR flips specific bits: BITXOR(value, mask). Apply the same XOR twice to get the original value back — this is the basis of XOR encryption.

Self-XOR is always zero

BITXOR(x, x) = 0 for any x. Every bit matches, so all results are 0. This property is used in algorithms to detect duplicates.

Find differing bits

BITXOR highlights which bits differ between two values. A result of 0 means the values are identical. Non-zero means they differ.

Try BITXOR in Viztab

Import your data and use BITXOR with 370+ other formulas. No signup required.

Open Viztab

Related Formulas