Excel BITOR function
The BITOR function returns the bitwise ‘OR’ of two given numbers.
Note: This function is only available in Excel 2013 and later versions.
- Number1 (required): This argument must be in decimal form greater than or equal to 0;
- Number2 (required): This argument must be in decimal form greater than or equal to 0.
1. Arguments can be either of:
-- Cell references that contain numbers.
2. The #NUM! error value occurs if either of the following conditions is met:
-- Any of the supplied numbers is less than 0;
-- Any of the supplied numbers is greater than (2^48)-1.
3. The #VALUE! error value occurs if either of the supplied numbers is non-numeric.
4. In the result, if any bit of the parameter is 1 in that bit position, the bit will be 1.
-- For example, to calculate BITOR (13,20). The binary form of 13 is 1101, and the binary form of 20 is 10100. These two binary representations will be added as follows:
Tips: As these two binaries have different digits, to help with comparison, 1101 can be considered as 01101.
It returns a numeric value.
To calculate the bitwise ‘OR’ of the given numbers in the table below, you can do as follows.
Select a cell (says D6 in this case), enter the formula below and press Enter to get the bitwise ‘OR’ of the first two numbers. Select this result cell and then drag its AutoFill Handle down to get other results.
1) Arguments in the formula above are supplied as cell references that contain numbers. However, you can change the formula as follows:
2) How does this BITOR function work?
Take the formula in D6 as an example: =BITOR(B6,C6)
2.1) First, the function converts the decimal number to binary.
In this case, the binary form of the decimal number ‘1’ is 1, and the binary form of the decimal number ‘4’ is 100.
You can apply the DEC2BIN function
to easily convert a decimal number to binary in Excel.
2.2) Then the function adds these two binary representations.
In this case, the sum of these two binaries is 101.
2.3) Finally the function converts the binary number back to a decimal form.
In this case, the binary number 101 is returned in decimal form as an integer number 5.
You can apply the BIN2DEC function
to easily convert a binary to decimal in Excel.
The following table shows how this function works in details.
The Best Office Productivity Tools
- One second to switch between dozens of open documents!
- Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
- Increases your productivity by 50% when viewing and editing multiple documents.
- Brings Efficient Tabs to Office (include Excel), Just Like Chrome, Edge and Firefox.
Please leave your comments in English