BITAND
Bit by bit AND of two whole numbers: a bit is set where both have it.
Group: Math. Compatible with DAX.
Syntax
BITAND ( <number1>, <number2> )
| Parameter | Type | Description |
|---|---|---|
number1 | Whole number | The first whole number. |
number2 | Whole number | The second whole number. |
Returns
Whole number. A number with only the bits that both numbers have set.
Remarks
- 12 is 1100 in binary and 10 is 1010; the bits they share make 1000, which is 8.
- Numbers with decimals are rounded to whole numbers first, a half away from zero. Negative numbers take part in 64-bit two's complement.
BITAND ( -1, 255 )is 255. - When either number is blank, the result is BLANK.
- It tests flags kept together in one number:
BITAND ( [Flags], 4 ) <> 0is TRUE when the flag worth 4 is on.
Examples
Shared bits
EVALUATE
ROW (
"12 and 10", BITAND ( 12, 10 ),
"Flag 4 in 13", BITAND ( 13, 4 ) <> 0,
"Flag 4 in 9", BITAND ( 9, 4 ) <> 0,
"With a blank", BITAND ( BLANK (), 3 )
)
| 12 and 10 | Flag 4 in 13 | Flag 4 in 9 | With a blank |
|---|---|---|---|
| 8 | TRUE | FALSE | (blank) |