The BITXOR function in Google Sheets performs a bitwise XOR (exclusive OR) operation on two numbers, comparing their binary representations bit by bit. It's commonly used in low-level data processing, flag manipulation, and encoding tasks. Dive into our comprehensive guide to master its application.
Parameters
value1: The first number to compare, treated as its binary representation.value2: The second number to compare, treated as its binary representation.
Step-by-Step Tutorial
-
Using
BITXORwith two numbers:- Example:
=BITXOR(5, 3) - Result:
6(binary101XOR011=110)
- Example:
-
Using
BITXORto toggle bits:- Example:
=BITXOR(12, 5) - Result:
9
- Example:
Use Cases and Scenarios
- Data Encoding: Combine or scramble binary flags for lightweight encoding schemes.
- Bitmask Toggling: Flip specific bits on or off within a bitmask value.
- Low-Level Data Comparison: Detect differences between two binary-encoded values.
Related Functions
BITAND: Bitwise AND of two numbers.BITOR: Bitwise OR of two numbers.BITLSHIFT: Shifts the bits of a number to the left by a specified number of positions.