BITXOR Function

Excel 2013+

Summary

The BITXOR function performs a bitwise Exclusive OR operation between two numbers, returning a decimal result where each bit is set to 1 only when the corresponding bits in the input numbers differ.

Syntax

BITXOR(number1, number2)

Parameters

Parameter Type Required Description
number1 Number Yes First non-negative integer for XOR operation
number2 Number Yes Second non-negative integer for XOR operation

Using the BITXOR Function

BITXOR is invaluable for low-level binary operations in Excel, such as data encoding, flag manipulation, cryptographic calculations, and bit-level comparisons. It compares each bit position between two numbers, setting result bits to 1 where input bits differ (one is 0, the other is 1).

Common BITXOR Examples

Basic BITXOR Calculation

=BITXOR(5,3)

Returns 6. Binary: 101 XOR 011 = 110 (4+2+0=6)

Flag Manipulation

=BITXOR(A1,1)

Toggles the least significant bit (bit 0) of the number in A1

Data Encoding

=BITXOR(BITAND(A1,15),85)

Encodes lower 4 bits of A1 using XOR with 85 (01010101)

Password Check

=BITXOR(12345,C1)

Simple XOR-based verification where C1 contains stored key

Frequently Asked Questions

BITXOR returns #NUM! error. Both arguments must be ≥0.

Numbers up to 2^48 - 1 (about 281 trillion). Larger values return #NUM!.

BITXOR works on individual bits, not decimal values. 5 XOR 3 = 6, but 5+3=8.

No, only integers. Non-integer values return #VALUE! error.

Common Errors and Solutions

#NUM!

Cause: Number < 0 or > 2^48-1

Solution: Use only non-negative integers within valid range

#VALUE!

Cause: Non-numeric input

Solution: Ensure both arguments contain numbers

Unexpected results

Cause: Misunderstanding bitwise vs arithmetic operations

Solution: Convert numbers to binary to verify XOR logic

Notes

  • Each '1' bit in result contributes 2^position to decimal value
  • Use BITAND for bits that are 1 in BOTH numbers
  • Use BITOR for bits that are 1 in EITHER number
  • Perfect for creating toggle operations (XOR same value twice returns original)
  • Common in checksum calculations and simple encryption

Compatibility

Available in: Excel 2013, Excel 2016, Excel 2019, Excel 2021, Excel 365, Excel for Web

Not available in: Excel 2010, Excel 2007, Excel 2003, Mac Excel 2011

Content last reviewed: December 9, 2025
Update frequency: As needed
Excel versions tested: Excel 2013+