Skip to main content

$bitOr

The $bitOr operator performs a bitwise OR operation on integer values.

Input

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

Output

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

Examples

Basic Bitwise OR

{
  "$bitOr": [
    5,
    3
  ]
}
Result: 7 (binary: 101 OR 011 = 111)

Multiple Values

{
  "$bitOr": [
    4,
    2,
    1
  ]
}
Result: 7 (binary: 100 OR 010 OR 001 = 111)

Field Value

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