BITOR

BITOR(field_1, field_2)[source]

Performs a bitwise OR operation between two numeric or hexadecimal inputs.

The bitwise OR operation compares each bit of the inputs and returns 1 if either bit at a given position are 1; otherwise, it returns 0. This function supports both integers and hexadecimal strings (interpreted as binary values) and will return a corresponding result in the same format.

If a string is provided as an input, it is interpreted as a hexadecimal number. This allows support for values larger than 32 bits, which are not representable using standard integers. Any non-hexadecimal character in a string is treated as ‘0’.

If both inputs are strings, the result is returned as a hexadecimal string; otherwise, the result is an integer. Array inputs are supported, but if both inputs are arrays, they must have the same length, else the formula will evaluate to an error.

Parameters:
  • field_1 (Operand | int | str) –

    The first value in the BITOR operation. Interpreted as a string of bits (either the binary representation of the integer value or hexadecimal string). If an array type, the operation is performed element-wise and the return will also be an array type.

    Supported types:

    • INTEGER

    • STRING

    • INTEGER_ARRAY

    • STRING_ARRAY

  • field_2 (Operand | int | str) –

    The second value in the BITOR operation. Interpreted as a string of bits (either the binary representation of the integer value or hexadecimal string). If an array type, the operation is performed element-wise and the return will also be an array type.

    Supported types:

    • INTEGER

    • STRING

    • INTEGER_ARRAY

    • STRING_ARRAY

Return type:

Formula

Returns:

A Formula object representing the bitwise OR result of the two inputs. If either input is an array type, the return will also be an array type. If both inputs are strings, the return type will also be a string; otherwise, it will be an integer. If either input is blank or in an error state, the formula evaluates to an error.

Supported types:

  • INTEGER

  • STRING

  • INTEGER_ARRAY

  • STRING_ARRAY

Raises:

ValueError – If the input data types are incompatible, unsupported, or if array lengths mismatch when both inputs are arrays.

Examples

With integer inputs:

BITOR(7, 3)
# Returns 7. (Binary: 0111 | 0011 = 0111)

With hexadecimal inputs:

BITOR("9", "A")
# Returns "0B". (Binary: 1001 | 1010 = 1011)