BITXOR Function

BITXOR Function

BITXOR Function

Perform a bitwise XOR operation on two integers. Useful for toggling bits, spotting changes, and checking where two bit patterns differ.

ExcelClash Team
PUBLISHED

Summary

BITXOR compares two integers at the bit level and keeps only the bits that are different. If the same bit is on in both values or off in both values, the result for that bit is 0.

That makes BITXOR useful for toggling flags and for spotting changes between two bit patterns. It is often the easiest way to answer questions like "what changed?" or "flip this one bit for me."

Purpose

Keep different bits

Returns only the bits that differ between the two inputs.

Return value

Number

Returns the decimal value of the resulting bit pattern.

Syntax

=BITXOR(number1, number2)

number1 and number2 are the integers you want to compare.

Excel compares the two bit patterns and returns 1 only where the bits are different. That makes BITXOR useful for toggling or highlighting change. The result is still shown as a regular decimal number.

Arguments

  • number1 - [required] The first non-negative integer.
  • number2 - [required] The second non-negative integer.

Both inputs must be whole numbers greater than or equal to 0. BITXOR is designed for bit patterns stored in decimal form, not text or negative values. If either argument is outside the supported limits, Excel returns an error.

BITXOR vs similar functions

BITXOR is for differences and toggles, not for overlap or simple union:

Function What it does Typical use Result
BITXOR Keeps only different bits Toggle or compare changes Number
BITAND Keeps only shared bits Check whether a flag is set Number
BITOR Keeps any on bit Turn flags on Number
= Checks whether two values are equal Simple value matching Boolean

Using BITXOR

The most common use is toggling a bit with a mask. If the target bit is off, BITXOR turns it on. If the target bit is on, BITXOR turns it off. That is why the same mask can be used to flip a state in either direction.

BITXOR is also useful for comparing two values. If two numbers are identical, their XOR result is 0. If the result is not zero, then at least one bit is different. That makes XOR a compact way to detect a change without comparing bits one by one.

Excel's bitwise functions work with non-negative integers and support values up to 2^48 - 1. If the inputs go outside that range, Excel returns #NUM!.

Example 1 - Compare 13 and 9

This keeps only the bits that differ between the two values.

=BITXOR(13, 9) // Returns 4
Check Answer
Challenge #1
Target: Sheet1!F1
Simple XOR Difference

Find the bitwise XOR of 13 and 9. Formula: =BITXOR(13, 9).

Example 2 - Toggle bit 8 in 13

This flips the target bit and leaves the others alone.

=BITXOR(13, 8) // Returns 5
Check Answer
Challenge #2
Target: Sheet1!F2
Hardware State Toggle

Flip bit-4 (8) in a register word value 13. Formula: =BITXOR(13, 8).

Example 3 - Compare a value with itself

Matching values produce zero because there is no difference left.

=BITXOR(127, 127) // Returns 0
Check Answer
Challenge #3
Target: Sheet1!F3
Identity Match Check

XOR 127 with 127 to confirm they match (Result 0). Formula: =BITXOR(127, 127).

Example 4 - Compare 64 and 1

This shows a simple result where the two values have different bits set.

=BITXOR(64, 1) // Returns 65
Check Answer
Challenge #4
Target: Sheet1!F4
48-Bit Cipher Mockup

Audit a data-mask using XOR 64 and 1. Formula: =BITXOR(64, 1).

Quick recap

  • Keeps different bits: BITXOR returns only the bits that do not match.
  • Useful for toggling: The same mask can turn a bit on or off.
  • Zero means no difference: If two values are the same, BITXOR returns 0.
  • Returns a number: The result is a decimal value, not a boolean.
  • Works only with non-negative integers: Excel returns #NUM! for values outside the supported range.
Tactical Arena
Select Scenario:
Share BITXOR Function!

Tell your friends about this post

Discussion

ExcelClash is an interactive platform designed to level up your Excel skills through real-world exercises and challenges. Sharpen your logic, solve real spreadsheet problems, and learn faster.

© 2026 ExcelClash, Inc. All rights reserved.