BITXOR function

BITXOR compares the binary representations of two integers and returns a new integer whose bits show exactly where the inputs differ.

=BITXOR(number1, number2)

Generate a BITXOR formula

Describe what you need. The generator will reach for BITXOR where BITXOR is the right tool, and tell you when it is not.

How to get a better answer
  • Name your columns by letter and by header: "column F (Net Value)" beats "the amount column".
  • State every condition, including the negatives — "not cancelled" changes the formula's shape.
  • Say where the data starts if it is not row 1, and whether it will grow.
  • Check the settings above match your spreadsheet: the wrong argument separator is a syntax error on your machine.

Arguments

How BITXOR reads its arguments
number1requirednumber2requiredBITXOR
ArgumentRequiredDescription
number1RequiredA non-negative integer (or cell reference containing one); decimal values are silently truncated to whole numbers before the operation.
number2RequiredA non-negative integer (or cell reference containing one); decimal values are silently truncated to whole numbers before the operation.

Returns

Returns an integer representing the bitwise XOR (exclusive OR) of the two input numbers.

Availability

Excel: All · Google Sheets: Supported

Worked examples

1. Compare on-hand inventory between warehouse locations

SKUWarehouseOn HandReorder PointCost
P001A12845
P001B15845
P002A81532
P002B81529
=BITXOR(C2, C3)

Result: 7

Warehouse A holds 12 units of P001 (binary 1100), Warehouse B holds 15 (binary 1111). BITXOR returns 7 (binary 0111), showing which bit positions differ in inventory. This flags warehouses with significantly different stock levels at a glance.

2. Detect pricing discrepancies across warehouse locations

SKUWarehouseOn HandReorder PointCost
P001A12845
P001B15845
P002A81532
P002B81529
=BITXOR(E4, E5)

Result: 13

SKU P002 costs 32 at Warehouse A (binary 100000) and 29 at Warehouse B (binary 011101). BITXOR returns 13 (binary 001101), indicating which bits differ. A non-zero result signals a pricing mismatch requiring reconciliation between locations.

3. Compare reorder thresholds between SKUs to audit restocking policies

SKUWarehouseOn HandReorder PointCost
P001A12845
P001B15845
P002A81532
P002B81529
=BITXOR(D2, D4)

Result: 7

SKU P001 has reorder point 8 (binary 1000), SKU P002 has 15 (binary 1111). BITXOR yields 7 (binary 0111), showing policy variation. Use this to audit whether different product categories follow consistent restocking rules or if thresholds have drifted.

Common errors

Which BITXOR error are you seeing?
BITXOR returned an error#VALUE!
Ensure both arguments are pure numbers or cell references containing only numeric values. Wrap text-as-numbers with VALUE(): =BITXOR(VALUE(A1), 15)
#NUM!
Verify both numbers are non-negative integers. If you have negatives, convert with ABS(): =BITXOR(ABS(A1), ABS(B1)), or filter them out before calling BITXOR.
#NAME?
Confirm the spelling is exactly BITXOR. If unavailable, check your platform's function library or use BITOR and BITAND in combination to simulate XOR behavior.
ErrorWhy it happensHow to fix it
#VALUE!One or both arguments contain text, TRUE/FALSE values, or reference cells with non-numeric content instead of numbers.Ensure both arguments are pure numbers or cell references containing only numeric values. Wrap text-as-numbers with VALUE(): =BITXOR(VALUE(A1), 15)
#NUM!One or both arguments are negative integers or exceed the platform's supported range (typically –2,147,483,648 to 2,147,483,647); BITXOR does not support negatives.Verify both numbers are non-negative integers. If you have negatives, convert with ABS(): =BITXOR(ABS(A1), ABS(B1)), or filter them out before calling BITXOR.
#NAME?The function name is misspelled (e.g., BITXR, XORBIT) or BITXOR is not available in your spreadsheet version (older platforms lack bitwise functions).Confirm the spelling is exactly BITXOR. If unavailable, check your platform's function library or use BITOR and BITAND in combination to simulate XOR behavior.

Tips and when to use something else

  • Decimal inputs are truncated silently; 32.99 becomes 32 before the XOR. Use ROUND() or INT() for explicit control if precision matters.
  • A BITXOR result of 0 means both numbers are identical in binary—a fast equality check for encoded flags or status codes.
  • Do not confuse BITXOR (bitwise operation returning a number) with XOR() (logical function returning TRUE/FALSE). Use XOR() for conditional statements, BITXOR() for bit-level data analysis.
  • BITXOR is specialized for technical and bit-flag scenarios; most business problems are solved faster with IF(), VLOOKUP, or XOR(). Reach for BITXOR only when working with encoded data or binary representations.

Frequently asked questions

How do I use BITXOR to flag when two warehouses have different inventory patterns?
Compare the on-hand values from two locations with BITXOR. If the result is 0, the quantities are identical in binary; any other result means they differ. Wrap it in IF() for readability: =IF(BITXOR(C2,C3)=0,"Match","Different") to mark mismatches in a summary column.
Why does BITXOR fail with negative numbers?
Bitwise operations are mathematically defined only for non-negative integers. Negative values trigger #NUM!. If your dataset includes negatives, use ABS() to convert them first, or filter them before applying BITXOR.
Can BITXOR work with prices like 29.99 or 45.67?
BITXOR truncates decimals to integers automatically; 29.99 becomes 29, losing precision. To preserve cents, multiply by 100 first (29.99 → 2999), apply BITXOR, then divide by 100: =BITXOR(E4*100,E5*100)/100.
What's the practical difference between BITXOR and XOR?
XOR() is a logical function that returns TRUE when inputs have different truth values (useful for boolean conditions). BITXOR() compares integers bit-by-bit and returns a numeric result (useful for encoded data). Choose XOR() for IF statements, BITXOR() for inventory or flag analysis.

Need a different formula?

The full generator is not scoped to one function — describe any spreadsheet problem and it will pick.

Open the formula generator

Reviewed 2026-09-17