Site icon Best Excel Tutorial

How to Use BITOR Function in Excel: Bitwise OR Operations

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:

2. Step-by-Step: Use BITOR for Bitwise Operations

✅ Step 1: Enter Your Numbers in Excel Cells

  1. Open your Excel spreadsheet
  2. In cell A1, enter your first number (for example: 12)
  3. In cell B1, enter your second number (for example: 10)
  4. Leave cell C1 empty for the BITOR result

✅ Step 2: Write the BITOR Formula

  1. Click on cell C1 where you want the result
  2. Type the formula: =BITOR(A1,B1)
  3. Press Enter
  4. 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

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.

  1. Check if your numbers are really positive integers between 0 and 2^53
  2. Make sure you’re using correct cell references or valid numbers in the formula.
  3. 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.

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!

Exit mobile version