
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.
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 keeps any bit that is on in either value.
=BITOR(13, 8) // Returns 13
Find the bitwise OR of 13 and 8. Formula: =BITOR(13, 8).
This combines two separate bit values into one result.
=BITOR(8, 16) // Returns 24
Set bit 4 (8) and bit 5 (16) in a new word. Formula: =BITOR(8, 16).
This is a simple way to build a combined permission value.
=BITOR(1, 2) // Returns 3
Combine Read (1) and Write (2) for a user. Formula: =BITOR(1, 2).
This adds the target bit without changing unrelated bits.
=BITOR(1024, 1) // Returns 1025
Perform OR on 1024 and 1. Formula: =BITOR(1024,1).
#NUM! for values outside the supported range.Tell your friends about this post