BITOR in Excel: Combine Flags Without Double Counting
Combine bit masks in Excel with BITOR, set a flag idempotently and see why adding overlapping flags produces a different result.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: BITOR(number1,number2) combines the set bits of two numeric masks and returns a decimal number. A bit present in either input appears once in the result, even when both inputs already contain it.
Availability and version history
- Introduced: the Microsoft function catalogue marks this identity as an Excel 2013 addition. An exact first build or preview date is not established.
- Availability: official help lists Excel for Microsoft 365, Excel for Microsoft 365 for Mac, Excel 2024, Excel 2024 for Mac, Excel 2021, Excel 2021 for Mac, Excel 2019, Excel 2016.
- Checked: October 14, 2026; official BITOR reference. Documentation and independent models; no native Excel execution or wider platform certification.
Syntax and documented scope
=BITOR(number1,number2)
Both arguments are required and nonnegative. Microsoft documents a maximum input of 2^48−1, or 281474976710655. Values outside the stated constraints produce #NUM!; nonnumeric arguments produce #VALUE!.
This guide uses nonnegative integers. The short BITOR reference does not separately explain fractional-number handling, so that behavior is not imported from BITAND. Numeric text, blank coercion and extreme boundary execution also remain untested.
The return value is the decimal sum of the selected bit weights, not a TRUE/FALSE condition. For logical alternatives such as region=“East” or amount>100, use OR instead.
Example 1: merge two sets of report flags
Use fictional bit weights 1 for summary, 2 for detail, 4 for chart and 8 for appendix. Enter these decimal masks in A1:B4:
| A, first mask | B, second mask |
|---|---|
| 5 | 12 |
| 3 | 8 |
| 6 | 6 |
In C2 enter and fill through C4:
=BITOR(A2,B2)
The results are 13, 11 and 6. For the first row, 5 is 0101 and 12 is 1100; the combined bits are 1101, or 8+4+1=13. The chart bit 4 appears in both inputs but is retained only once.
For the second row, 3 contains summary and detail, and 8 supplies appendix. Their bits do not overlap, so the combination is 11. The last row demonstrates that combining a mask with itself leaves it unchanged.
In D2 enter =A2+B2 and fill down. The arithmetic sums are 17, 11 and 12. Only the middle sum matches BITOR, because that row has no overlapping set bits.
Example 2: set a flag without toggling it
Enter 1, 5, 8 and 12 in F2:F5. These are four existing configurations. Put the desired chart flag, 4, in H1.
=BITOR(F2,$H$1)
Enter that formula in G2 and fill through G5. The expected updated masks are 5, 5, 12 and 12. Each result now includes chart. Configurations that already included chart stay unchanged.
In I2 use =BITOR(G2,$H$1) and fill down. The results remain 5, 5, 12 and 12. Reapplying this operation is idempotent: it sets the bit rather than reversing its state.
That distinction matters in a repeatable import or report refresh. BITXOR is useful for toggling bits, but applying XOR twice restores the original mask. Choose the operation that matches the intended workflow.
Advanced example: combine three sources and audit overlap
Enter 5, 10 and 4 in K2:K4. These represent proposed flags from three configuration sources. Combine them with a nested formula:
=BITOR(BITOR(K2,K3),K4)
The expected result is 15. The first two masks produce 15, and the third contributes a chart bit already present. Adding the three numbers instead gives 19, which misrepresents the flag set.
For two inputs, an independently checkable relationship is:
=BITOR(A2,B2)+BITAND(A2,B2)
On the first example row, BITOR is 13 and BITAND is 4, so the total is 17, matching 5+12. The intersection explains the amount by which simple addition double-counted the shared flag weights.
To confirm that all four fictional options are present, compare =BITAND(15,15)=15, which is TRUE. With a combined result of 13, the equivalent test is FALSE because the detail bit is missing.
Practical cautions
A zero mask contributes no bits: =BITOR(9,0) returns 9. Reversing the inputs also preserves the combination: =BITOR(5,12) and =BITOR(12,5) both return 13.
The function does not know what a bit means. Keep a separate option-to-weight table and prohibit conflicting or undocumented fields in your data design. A correct bitwise result cannot validate an application-specific permission model.
Use DEC2BIN only for small values within its separate −512 to 511 input range when showing binary illustrations. BITOR’s wider numeric input allowance does not expand DEC2BIN’s converter range.
References and verification
Expected outputs are independently calculated examples or documented rules, not captured native Excel results. Formulas use English function names and comma argument separators. Locale, rendering and boundary restrictions are stated where relevant.