
Perform a bitwise OR operation on two integers. Useful for turning flags on, combining masks, and building up bit-based values.
BITOR compares two integers at the bit level and keeps any bit that is 1 in either value. If a bit is on in one input or both inputs, it stays on in the result.
This makes BITOR useful when you want to turn flags on or combine several bit-based values into one number. It is a safer fit than normal addition when you are working with flags, because it keeps existing bits on instead of changing the meaning through carry rules.
BITOR is helpful when the goal is to combine settings rather than inspect them. It keeps every bit that is on in either input, which makes it a natural tool for building flag values, merging masks, or turning specific options on without disturbing the rest of the stored pattern.
Returns any bit that is on in either input.
Returns the decimal value of the combined bit pattern.
=BITOR(number1, number2)
number1 and number2 are the integers you want to combine.
Excel checks both binary patterns and turns a bit on in the result if either input has that bit on. The final answer is returned as a decimal number, so the function feels like normal Excel output even though it is doing bitwise logic underneath.
Both arguments must be whole numbers that are 0 or larger. These are usually ordinary decimal values used as flag containers. If either input is negative, too large, or not numeric, Excel returns an error instead of performing the bitwise OR.
BITOR is for turning bits on, not for checking overlap or toggling changes:
| Function | What it does | Typical use | Result |
|---|---|---|---|
BITOR |
Keeps any bit that is on in either input | Turn flags on or combine masks | Number |
BITAND |
Keeps only shared bits | Check whether a flag is set | Number |
BITXOR |
Keeps only different bits | Toggle or compare changes | Number |
+ |
Adds numbers normally | Regular arithmetic | Number |
The main use is turning on one or more target bits. If a bit is already on, BITOR leaves it on. If it is off and the mask includes that bit, BITOR turns it on. That makes it a good fit when you want to enforce a state without first checking every bit manually.
This is especially useful for flags and permissions. A value like BITOR(1, 2) combines two separate permission bits into 3. More importantly, if one of those bits is already present, BITOR does not break the value by adding it twice.
Excel's bitwise functions work with non-negative integers and support values up to 2^48 - 1. If the inputs go outside that range, Excel returns #NUM!.
This example combines two values and keeps every bit that is turned on in either one. Unlike BITAND, the bit does not need to appear in both numbers to survive.
That makes BITOR useful when you want to merge flags or settings into one result. It creates a combined state instead of checking overlap.
=BITOR(13, 8) // Returns 13
Find the bitwise OR of 13 and 8.
Here the two numbers represent separate flags. The formula turns both of them on in the final result, which is why the answer becomes 24 instead of choosing one value over the other.
This is a common pattern when one number needs to store several enabled options at the same time. Each flag keeps its place, and the result becomes one combined mask.
=BITOR(8, 16) // Returns 24
Set bit 4 (8) and bit 5 (16) in a new word.
This example is easier to read because the numbers are small. The value 1 and the value 2 represent different permission bits, and BITOR combines them into one permission number.
The result 3 means both underlying bits are now on. That is often clearer than trying to create the combined number by memory or by ordinary addition.
=BITOR(1, 2) // Returns 3
Combine Read (1) and Write (2) for a user.
In this example, the value already has one high bit set and the mask adds a different low bit. BITOR turns on the new bit while leaving the other one alone.
That is why it is useful for forcing a flag on. You can add one specific bit without disturbing the rest of the stored pattern.
=BITOR(1024, 1) // Returns 1025
Perform OR on 1024 and 1.
BITOR is the function to use when you want the combined pattern from two values. In this lesson, the key idea was that any bit that is on in either input stays on in the final result, which makes BITOR a clean way to build or update flag-based numbers.
That matters because bit fields often represent settings or permissions packed into one number. With BITOR, you can force a flag on without rewriting the whole pattern by hand, and without the ambiguity that can come from treating flags like ordinary addition.
#NUM! for values outside the supported range.Tell your friends about this post