BITXOR function
BITXOR compares two numbers bit by bit and keeps the bits that differ between them, returning a whole number. Negative or fractional inputs return #NUM!.
Example
Read it as a sentence: compare 12 and 10 bit by bit and keep the bits that are on in only one of them, which gives 6.
A
B
C
D
1
6
2
3
Syntax
BITXOR(number1, number2)
-
number1(required) - A whole number of 0 or more, below 2^48.
-
number2(required) - A second whole number of 0 or more, below 2^48.
Returns: A whole number.
What Excel actually returns
Each formula below was run in desktop Excel. The result is exactly what the cell showed, errors included.
| Formula | Excel shows | Case |
|---|---|---|
=BITXOR(13,25) | 20 | 13,25 |
=BITXOR(0,0) | 0 | 0,0 |
=BITXOR(2^48-1,1) | 2.81475E+14 | 2^48-1 |
=BITXOR("13","25") | 20 | Text number |
=BITXOR(TRUE,1) | 0 | TRUE |
=BITXOR({1,2,3},3) | 2 | Spill |
=BITXOR(-1,1) | #NUM! | Negative |
=BITXOR(1.5,1) | #NUM! | Decimal |
Watch out for
- Negative or fractional inputs return #NUM!.
Where it works
- Excel
- BITXOR arrived in Excel 2013. Older versions do not have it.
- Google Sheets
- Same name, same behaviour for everyday use.
Part of Engineering functions. Every result on this page was measured in desktop Excel, build 16.0.20527. Last updated .