OpenBI Docs Buy

BITXOR

Compares two whole numbers bit by bit and keeps the bits where they differ (exclusive or).

Group: Math. Compatible with DAX.

Syntax

BITXOR ( <number1>, <number2> )
ParameterTypeDescription
number1Whole numberThe first whole number.
number2Whole numberThe second whole number.

Returns

Whole number. A number with the bits that exactly one of the two numbers has set.

Remarks

  • 12 is 1100 in binary and 10 is 1010; the bits where they differ make 0110, which is 6.
  • Applying the same number twice gives the first back: BITXOR ( BITXOR ( 12, 10 ), 10 ) is 12. It flips flags: BITXOR ( [Flags], 4 ) turns the flag worth 4 on when it is off, and off when it is on.
  • Numbers with decimals are rounded to whole numbers first, a half away from zero. Negative numbers take part in 64-bit two's complement.
  • A blank counts as 0 next to a number; when both are blank, the result is BLANK.

Examples

Bits that differ

EVALUATE
ROW (
    "12 xor 10", BITXOR ( 12, 10 ),
    "Twice gives back", BITXOR ( BITXOR ( 12, 10 ), 10 ),
    "Blank and 3", BITXOR ( BLANK (), 3 )
)
12 xor 10Twice gives backBlank and 3
6123

BITAND, BITOR, BITRSHIFT.

Last updated · OpenBI Studio 0.3.74