BITOR Function
BITOR Function

BITOR Function

Perform a bitwise OR operation on two integers. Useful for turning flags on, combining masks, and building up bit-based values.

ExcelClash Team
PUBLISHED

Summary

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.

Purpose

Combine bits

Returns any bit that is on in either input.

Return value

Number

Returns the decimal value of the combined bit pattern.

Syntax

=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.

Arguments

  • number1 - [required] The first non-negative integer.
  • number2 - [required] The second non-negative integer.

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 vs similar functions

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

Using BITOR

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!.

Example 1 - Combine 13 and 8

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
Check Answer
Challenge #1
Target: Sheet1!D1

Find the bitwise OR of 13 and 8.

Example 2 - Turn on two flags

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
Check Answer
Challenge #2
Target: Sheet1!D2

Set bit 4 (8) and bit 5 (16) in a new word.

Example 3 - Combine permission bits

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
Check Answer
Challenge #3
Target: Sheet1!D3

Combine Read (1) and Write (2) for a user.

Example 4 - Force one high bit on

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
Check Answer
Challenge #4
Target: Sheet1!D4

Perform OR on 1024 and 1.

Conclusion Recap

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.

  • Keeps any on bit: BITOR returns the union of the two bit patterns.
  • Useful for enabling flags: It is a clean way to force a bit on.
  • Better than plain addition for flags: It avoids changing meaning through duplicate adds.
  • Returns a number: The result is a decimal value, not a boolean.
  • Works only with non-negative integers: Excel returns #NUM! for values outside the supported range.
Tactical Arena
Share BITOR Function!

Tell your friends about this post

Discussion

ExcelClash is an interactive platform designed to level up your Excel skills through real-world exercises and challenges. Sharpen your logic, solve real spreadsheet problems, and learn faster.

© 2026 ExcelClash, Inc. All rights reserved.