Back to Functions

BITXOR

Bitwise XOR (exclusive OR) of 2 numbers.

EngineeringBITXOR(value1, value2)

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

  1. Using BITXOR with two numbers:

    • Example: =BITXOR(5, 3)
    • Result: 6 (binary 101 XOR 011 = 110)
  2. Using BITXOR to toggle bits:

    • Example: =BITXOR(12, 5)
    • Result: 9

Use Cases and Scenarios

  1. Data Encoding: Combine or scramble binary flags for lightweight encoding schemes.
  2. Bitmask Toggling: Flip specific bits on or off within a bitmask value.
  3. 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.

Related Articles

Newsletter

More BITXOR examples coming soon.

We are building short, practical updates for Sheets power users.