Need to combine binary numbers using bitwise OR operations in Excel? The BITOR function lets you merge two numbers at the bit level and return the result, without needing to manually convert to binary. This guide shows you how, step-by-step.
1. Understand BITOR Function Logic
By default, BITOR compares two numbers bit by bit and returns 1 where either number has a 1 in that position. So before you use BITOR, you must:
- Understand that it works with positive integers only (0 to 2^53-1)
- Know that the result includes any 1 found in either number at each bit position
2. Step-by-Step: Use BITOR for Bitwise Operations
✅ Step 1: Enter Your Numbers in Excel Cells
- Open your Excel spreadsheet
- In cell A1, enter your first number (for example: 12)
- In cell B1, enter your second number (for example: 10)
- Leave cell C1 empty for the BITOR result
✅ Step 2: Write the BITOR Formula
- Click on cell C1 where you want the result
- Type the formula: =BITOR(A1,B1)
- Press Enter
- Excel calculates the bitwise OR and displays the result (in this case: 14)
Now the formula is complete. BITOR combined both numbers by including any bit that was 1 in either number.
3. Tips for Better BITOR Operations
- Use cell references instead of hard-coded numbers so you can change values without editing the formula
- Combine with other bitwise functions like BITAND and BITXOR for more complex operations
- Add comments to your formulas to explain which flags or permissions you’re setting
4. Bonus: Advanced BITOR with Permission Flags
Want even more control? You can use BITOR to combine multiple permission flags or settings. Here’s an example:
Example 1: Combine two permission flags
Flag1: 4 (binary: 0100 = Read permission)
Flag2: 8 (binary: 1000 = Write permission)
Formula: =BITOR(A1, B1)
Result: 12 (binary: 1100 = Read + Write)
Example 2: Set multiple permissions at once
ReadFlag: 1
WriteFlag: 2
DeleteFlag: 4
Formula: =BITOR(BITOR(ReadFlag, WriteFlag), DeleteFlag)
Result: 7 (all three permissions combined)
Example 3: Enable a specific bit without losing others
CurrentSettings: 5 (binary: 0101)
NewBit: 2 (binary: 0010)
Formula: =BITOR(CurrentSettings, NewBit)
Result: 7 (binary: 0111 = original + new bit)
This approach lets you combine multiple flags or settings without overwriting existing ones.
Troubleshooting BITOR Functions
Sometimes users say that BITOR returns unexpected results or errors.
- Check if your numbers are really positive integers between 0 and 2^53
- Make sure you’re using correct cell references or valid numbers in the formula.
- Review the binary representation of your numbers—BITOR should return a value that includes bits from both numbers.
Another common issue is that BITOR returns #NUM! error or unexpected values.
- Make sure both numbers are whole numbers, not decimals (BITOR doesn’t work with decimals).
- Verify that neither number is negative—BITOR requires non-negative integers.
- Check that your numbers don’t exceed 2^53-1, which is Excel’s limit for integer precision.
Learning how to use BITOR in Excel is a great way to combine flags, permissions, or binary settings. You don’t have to manually calculate which bits to include—let BITOR merge them and focus on your data.
Try it out and master bitwise operations in Excel today!
