BITXOR in Google Sheets: Track Changed Flags and Document Coercion
Find changed bits with Google Sheets BITXOR, separate enabled from disabled flags and reproduce the documented numeric-text and Boolean coercions.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: BITXOR(value1,value2) returns the numeric mask of differing bit positions. It can detect changed options or toggle chosen bits. Google also documents coercion of text “3” to 3 and Boolean TRUE to 1.
Availability and version history
- Introduced: first introduction date is not established by the reviewed official history; no desktop release number is inferred.
- Availability: documented in the rolling Google Sheets service; these examples use the web worksheet workflow.
- Checked: October 14, 2026; official BITXOR reference. Documentation and independent models, with no native Sheets execution or wider client certification.
Syntax and what the output means
=BITXOR(value1,value2)
The two required inputs are compared bit by bit. Equal bits produce zero; different bits produce one. Reversing the arguments leaves the result unchanged.
This differs from logical XOR, which returns TRUE for an odd number of true conditions. BITXOR can encode several changed positions in one decimal result. A result of 5 means bits with weights 4 and 1 differ, not that five conditions changed.
The Google page documents the small coercion examples above but does not provide a complete input-size, fractional-input or error-code policy. Those details remain unverified rather than being copied from another spreadsheet.
Example 1: compare old and new report settings
Define fictional report weights CSV=1, PDF=2, charts=4, archive=8 and metadata=16. Enter the following in A1:B4:
| A, old mask | B, new mask |
|---|---|
| 22 | 19 |
| 6 | 6 |
| 0 | 9 |
In C2 enter and fill through C4:
=BITXOR(A2,B2)
The results are 5, 0 and 9. The first comparison is 10110 versus 10011. CSV and charts differ, giving 00001+00100=00101, or decimal 5. PDF and metadata remain selected in both.
Put weights 1, 2, 4, 8 and 16 in E2:E6. In F2 enter =BITAND($C$2,E2)>0 and fill down. The outputs are TRUE, FALSE, TRUE, FALSE and FALSE, locating the changed positions.
A zero difference means the two numeric masks agree. It does not establish that either configuration is valid according to the report’s requirements.
Example 2: distinguish added and removed options
For the first pair, C2 is the difference mask 5. Use:
=BITAND(C2,B2)
=BITAND(C2,A2)
The first result is 1, the changed bit present in the new mask. The second result is 4, the changed bit present in the old mask. CSV was enabled and charts were disabled.
For the second pair, both added and removed masks are zero. For the final pair, added is 9 and removed is zero. Inspecting both sides avoids treating every change as an addition.
The arithmetic difference 19−22 is −3, which is not the changed-bit mask 5. Numeric subtraction measures a change in the encoded integer, not a list of changed option positions.
Advanced example: toggle once, then repeat
Enter 2, 10, 16 and 24 in H2:H5. Toggle the archive bit with =BITXOR(H2,8) in I2 and fill down. Expected results are 10, 2, 24 and 16.
In J2 use =BITXOR(I2,8) and fill down. The original masks 2, 10, 16 and 24 return. A repeated toggle cancels itself.
If the intended operation is “ensure archive is on,” BITOR is different: =BITOR(H2,8) yields 10, 10, 24 and 24. Choose a toggle only when reversing the previous state is the desired action.
Advanced example: inspect documented coercion
Google explicitly permits the following input conversions: text “3” can become numeric 3, and TRUE can become 1. Applying those stated rules gives:
| Formula | Coerced comparison | Expected result |
|---|---|---|
=BITXOR("3",1) |
3 XOR 1 | 2 |
=BITXOR(TRUE,2) |
1 XOR 2 | 3 |
=BITXOR("3",TRUE) |
3 XOR 1 | 2 |
These are independently calculated applications of the documented conversions, not a blanket statement that arbitrary labels or all logical/error inputs are accepted. A formula that succeeds after coercion may conceal inconsistent input types in an import.
For an audit trail, retain the original values alongside any normalized numeric fields. Do not use a successful BITXOR result as the only test that a source field had the intended type.
Cross-checks and limits
=BITXOR(22,5) reconstructs the new mask 19 from the old mask and the difference. =BITXOR(6,6) returns zero, while =BITXOR(6,0) returns 6. These identities help check a small record comparison.
BITAND inspects shared bits; BITXOR identifies different bits. Neither operation establishes authorization, encryption or record integrity. Large widths, negative values, fractions and error precedence remain outside the verified documentation-and-model scope.
References and verification
Examples use fictional data, English function names and comma separators. Expected outputs are independent mathematical calculations or explicitly documented rules, not native Sheets captures. Check the spreadsheet locale when reproducing punctuation-sensitive formulas.