Skip to main content

$bitAnd

The $bitAnd operator performs a bitwise AND operation on integer values.

Input

  • An array of integer values (at least 2 values required)

Output

  • The result of performing a bitwise AND operation on all input values

Examples

Basic Bitwise AND

{
  "$bitAnd": [
    5,
    3
  ]
}
Result: 1 (binary: 101 AND 011 = 001)

Multiple Values

{
  "$bitAnd": [
    15,
    7,
    3
  ]
}
Result: 3 (binary: 1111 AND 0111 AND 0011 = 0011)

Field Value

{
  "$bitAnd": [
    {
      "$input": "flag1"
    },
    {
      "$input": "flag2"
    }
  ]
}
Result: The bitwise AND of flag1 and flag2 fields