< Back

BITOR function

Mon Jul 22, 2019 5:03 am

BITOR function



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.
The Symbol for OR gate is:



Image



Where A and B are inputs and X is the result. The result for each bit combination is as per the table below:



A


B


X


0


0


0


0


1


1


1


0


1


1


1


1


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


=BITOR(21,10)


Returns the total of the bitwise "Or" operation at each bit position.


31


=BITOR(21,15)
Returns the total of the bitwise "Or" operation at each bit position. 31
=BITOR(11,8) Returns the total of the bitwise "Or" operation at each bit position. 11




How is it Calculated?

21 in Binary : 10101

10 in Binary : 01010

10101 OR

01010

=11111

Decimal of 11111 : 31