Applies ToExcel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2024 Excel 2024 for Mac Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2016

This article describes the formula syntax and usage of the BITOR function in Microsoft Excel.

Description

Returns a bitwise 'OR' of two numbers.

Syntax

BITOR(number1, number2)

The BITOR function syntax has the following arguments.

  • Number1    Required. Must be in decimal form and greater than or equal to 0.

  • Number2    Required. Must be in decimal form and greater than or equal to 0.

Remarks

  • The result is a bitwise 'OR' of its parameters.

  • In the result, each bit position is 1 if any of the parameter's bits at that position are 1.

  • The values returned from the bit positions progress from right to left as powers of 2. The rightmost bit returns 1 (2^0), the bit to the left returns 2 (2^1), and so on.

  • If either argument is outside their constraints, BITOR returns the #NUM! error value.

  • If either argument is greater than (2^48)-1, BITOR returns the #NUM! error value.

  • If either argument is a non-numeric value, BITOR returns the #VALUE! error value.

Example

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.

Formula

Description

Result

How it works

=BITOR(23,10)

Compares the bit positions for the binary representations of the two numbers, and if either position contains 1, returns 2 raised to a power, depending on bit position. Then, those numbers are summed.

31

The number 23 is 10111 in binary, and 10 is 1010. The value 1 is found in either position at all 5 positions of either of the two numbers. You can express 1010 as 01010 so that both numbers have the same number of digits. The numbers 2^0, 2^1, 2^2, 2^3, and 2^4 are summed, for a total of 31.

23 = 10111

10 = 01010

Test: Is 1 found at any of the 5 positions?

yyyyy

1+2+4+8+16=31

Top of Page

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.