How to Use the BITAND Function in Excel
In both Microsoft Excel and Google Sheets, the BITAND function is utilized to execute a bitwise AND operation between two numerical values. This function outputs a decimal number, which represents the result of the AND operation applied to the individual bits of the input numbers. In the resulting number, a bit is set to 1 only if the corresponding bits in both input numbers are also 1; otherwise, the bit is set to 0.
Overview of Syntax:
The syntax for the BITAND function is consistent across both Excel and Google Sheets:
=BITAND(number1, number2)
Here, number1
and number2
are the two decimal numbers upon which the bitwise AND operation will be performed.
Examples:
To better illustrate how the BITAND function operates, consider the following examples:
Example 1:
Imagine you need to determine the bitwise AND result for the numbers 5 and 3 in Excel or Google Sheets. The function would be applied as follows:
number1 | number2 | Result |
---|---|---|
5 | 3 | =BITAND(5, 3) |
The result of this operation is 1. This is because the binary representation of 5 is 101, and 3 is 011. The AND operation on each bit results in 001, which corresponds to 1 in decimal.
Example 2:
Consider a somewhat more complex scenario where the bitwise AND result for 15 and 9 is sought:
number1 | number2 | Result |
---|---|---|
15 | 9 | =BITAND(15, 9) |
The result of =BITAND(15, 9)
is 9. In binary terms, 15 is represented as 1111, and 9 as 1001. The AND operation across each bit results in 1001, which represents 9 in decimal.
Understanding and applying the BITAND function with these examples can help you proficiently perform bitwise AND operations in both Excel and Google Sheets.
More information: https://support.microsoft.com/en-us/office/bitand-function-8a2be3d7-91c3-4b48-9517-64548008563a