A to Z of Excel Functions: The BITAND Function
13 February 2017
Welcome back to our regular A to Z of Excel Functions blog. Today we look at the BITAND function.
The BITAND function
Now this is more like it. Finally, we get to functions used all of the time by your typical Excel user. Not.
This function returns a bitwise ‘AND’ of two numbers. For those of us without PhD’s in IT, this means that the value of each bit position (the corresponding number reading from right to left when represented in binary) is counted only if both parameter's bits at that position are 1.
The BITAND function employs the following syntax to operate:
The BITAND function has the following arguments:
- number1: this is required and must be in decimal form, greater than or equal to 0
- number2: also required. This too must be in decimal form and greater than or equal to 0.
It should be further noted that:
- 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.
Please see my example below:
We’ll continue our A to Z of Excel Functions soon. Keep checking back – there’s a new blog post every other business day.