BITXOR
TheBITXOR
function returns the bitwise XOR of two numbers. The function takes two numeric arguments and returns the result of the bitwise XOR operation performed on them.
- How to use
BITXOR
formula? - Examples of using
BITXOR
formula BITXOR
formula not working?- Similar formulas to
BITXOR
Usage
Use the BITXOR
formula with the syntax shown below, it has 2 required parameters:
- value1 (required):
The first number (or reference to a cell containing a number) to be used in the bitwise XOR operation. - value2 (required):
The second number (or reference to a cell containing a number) to be used in the bitwise XOR operation.
Examples
Here are a few example use cases that explain how to use theBITXOR
formula in Google Sheets.
Toggle Boolean Values
Using the BITXOR
function, you can toggle the values of Boolean variables. For example, if cell A1 contains a Boolean value of TRUE, you can toggle it to FALSE by using the formula =BITXOR(A1,TRUE)
.
Create Unique Identifiers
You can use the BITXOR
function to create a unique identifier by XORing the values of multiple cells. For example, if you have values in cells A1 and B1, you can create a unique identifier by using the formula =BITXOR(A1,B1)
.
Convert Binary to Decimal
You can use the BITXOR
function to convert binary numbers to decimal. For example, the formula =BITXOR(BIN2DEC("1010"),BIN2DEC("1100"))
will return the decimal value of 6.
Generate Random Numbers
You can use the BITXOR
function to generate random numbers. For example, the formula =BITXOR(RANDBETWEEN(1,100),RANDBETWEEN(1,100))
will generate a random number between 1 and 100.
Calculate Parity
The BITXOR
function can be used to calculate the parity of a set of bits. For example, the formula =BITXOR(BIN2DEC("110101"),BIN2DEC("110010"))
will return the parity of the binary numbers 110101 and 110010.
Common Mistakes
BITXOR
not working? Here are some common mistakes people make when using the BITXOR
Google Sheets Formula:
Using non-numeric inputs
BITXOR requires numeric inputs. If you try to use non-numeric inputs, such as text or empty cells, it will return an error.
Not using the correct syntax
BITXOR requires two inputs separated by a comma. If you use the wrong syntax, such as missing a comma, it will return an error.
Related Formulas
The following functions are similar to BITXOR
or are often used with it in a formula:
-
BITAND
The BITAND function returns a bitwise AND of two numbers. This function is commonly used in engineering applications where binary digits are manipulated to perform logical operations. The function takes two inputs, value1 and value2, and returns a decimal number that represents the bitwise AND of the two inputs.
-
BITOR
The
BITOR
function returns a bitwise OR of two numbers. -
BITLSHIFT
The BITLSHIFT function shifts the bits of a given number to the left or right by a specified number of positions. This function is commonly used in engineering and computer science to perform bitwise operations on binary numbers.
Learn More
You can learn more about the BITXOR
Google Sheets function on Google Support.