BITAND function: Description, Usage, Syntax, Examples and Explanation
What is BITAND function in Excel?
BITAND function is one of Engineering functions in Microsoft Excel that returns a bitwise ‘AND’ of two numbers.
Syntax of BITAND function
BITAND( number1, number2)
The BITAND function syntax has the following arguments.
- Number1: Must be in decimal form and greater than or equal to 0.
- Number2: Must be in decimal form and greater than or equal to 0.
BITAND formula explanation
- BITAND returns a decimal number.
- The result is a bitwise ‘AND’ of its parameters.
- The value of each bit position is counted only if both 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 its left returns 2 (2^1), and so on.
- If either argument is less than 0, BITAND returns the #NUM! error value.
- If either argument is a non-integer or is greater than (2^48)-1, BITAND returns the #NUM! error value.
- If either argument is a non-numeric value, BITAND returns the #VALUE! error value.
Example of BITAND function
Steps to follow:
1. Open a new Excel worksheet.
2. Copy data in the following table below and paste it in cell A1
Note: For formulas to show results, select them, press F2 key on your keyboard and then press Enter.
You can adjust the column widths to see all the data, if need be.
Formula | Description | Result | How it works |
=BITAND(1,5) | Compares the binary representations of 1 and 5. | 1 | The binary representation of 1 is 1, and the binary representation of 5 is 101. Their bits match only at the rightmost position. This is returned as 2^0, or 1. |
=BITAND(13,25) | Compares the binary representations of 13 and 25. | 9 | The binary representation of 13 is 1101, and the binary representation of 25 is 11001. Their bits match at the rightmost position and at the position fourth from the right. This is returned as (2^0)+ (2^3), or 9. |
Decimal number | Binary representation | ||
13 | 1101 | ||
25 | 11001 |