Number.BitwiseAnd
Combines two whole numbers bit by bit, keeping only the bits set in both.
Group: Number. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Number.BitwiseAnd(number1 as nullable number, number2 as nullable number) as nullable number
| Parameter | Type | Description |
|---|---|---|
number1 | nullable number | A whole number. |
number2 | nullable number | Another whole number. |
Returns
nullable number. The bits the two numbers share; null when either is null.
Remarks
- Handy for flags packed in one number: 1 = gift wrap, 2 = express, 4 = insured. A result other than 0 means the flag is set.
Examples
Is order 6 insured?
6 is express (2) plus insured (4).
Number.BitwiseAnd(6, 4) <> 0
true
The shared bits of 13 and 6
Number.BitwiseAnd(13, 6)
4
13 is 1101 in binary and 6 is 0110: only the 4 bit is in both.
Related functions
Number.BitwiseOr, Number.BitwiseXor, Number.BitwiseShiftRight.