Excel BITXOR function
The BITXOR function returns the bitwise ‘XOR’ of two given numbers.
Note: This function is only available in Excel 2013 and later versions.
- Number1 (required): This argument must be in decimal form greater than or equal to 0;
- Number2 (required): This argument must be in decimal form greater than or equal to 0.
1. Arguments can be either of:
-- Cell references that contain numbers.
2. The #NUM! error value occurs if any of the following conditions is met:
-- Any of the supplied numbers is not an integer;
-- Any of the supplied numbers is less than 0;
-- Any of the supplied numbers is greater than (2^48)-1.
3. The #VALUE! error value occurs if either of the supplied numbers is non-numeric.
4. In the result:
-- If the values of the parameter in that bit position are not equal (in the same bit position, one value is 1 and the other is 0), the final bit in that bit position will be 1.
-- If the values of the parameter in that bit position are equal (in the same bit position, both values are 1 or 0), the final bit in that bit position will be 0.
For example, to calculate BITXOR (13,20). The binary form of 13 is 1101, and the binary form of 20 is 10100. These two binary representations will be added as follows:
Tips: As these two binaries have different digits, to help with comparison, 1101 can be considered as 01101.
It returns a numeric value.
To calculate the bitwise ‘XOR’ of the given numbers in the table below, you can do as follows.
Select a cell (says D6 in this case), enter the formula below and press Enter to get the bitwise ‘XOR’ of the first two numbers. Select this result cell and then drag its AutoFill Handle down to get other results.
1) Arguments in the formula above are supplied as cell references that contain numbers. However, you can change the formula as follows:
2) How does this BITXOR function work?
Take the formula in D6 as an example: =BITXOR(B6,C6)
2.1) First, the function converts the decimal number to binary.
In this case, the binary form of the decimal number ‘1’ is 1, and the binary form of the decimal number ‘4’ is 100.
You can apply the DEC2BIN function
to easily convert a decimal number to binary in Excel.
2.2) Then the function adds these two binary representations.
In this case, the sum of these two binaries is 101.
2.3) Finally the function converts the binary number back to a decimal form.
In this case, the binary number 101 is returned in decimal form as an integer number 5.
You can apply the BIN2DEC function
to easily convert a binary to decimal in Excel.
The following table shows how this function works in details.
Excel BITOR function
The BITOR function returns the bitwise ‘OR’ of two given numbers.
Excel BITRSHIFT function
The BITRSHIFT function returns the given number shifted right by the specified number of bits.
Excel BITLSHIFT Function
The BITLSHIFT function returns a decimal number shifted left by a specified number of bits.
Excel BITAND function
The BITAND function returns a decimal number representing the bitwise 'AND' of two supplied numbers.
The Best Office Productivity Tools
- One second to switch between dozens of open documents!
- Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
- Increases your productivity by 50% when viewing and editing multiple documents.
- Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Edge and Firefox.