All Products
Search
Document Center

Simple Log Service:Bitwise functions

Last Updated:Jun 15, 2026

Bitwise functions perform bit-level AND, OR, XOR, NOT, and count operations on bigint values.

Log Service supports the following bitwise functions.

Important If you want to use strings in analytic statements, you must enclose strings in single quotation marks (''). Strings that are not enclosed or enclosed in double quotation marks ("") indicate field names or column names. For example, 'status' indicates the status string, and status or "status" indicates the status log field.

Function name

Syntax

Description

SQL support

SPL support

bit_count function

bit_count(x, bits)

Calculates the number of set bits (1s) in x.

bitwise_and function

bitwise_and(x, y)

Performs a bitwise AND operation on x and y.

bitwise_not function

bitwise_not(x)

Performs a bitwise NOT operation on x.

bitwise_or function

bitwise_or(x, y)

Performs a bitwise OR operation on x and y.

bitwise_xor function

bitwise_xor(x, y)

Performs a bitwise XOR operation on x and y.

bit_count

Calculates the number of set bits (1s) in x.

Syntax

bit_count(x, bits)

Parameters

Parameter

Description

x

A bigint value.

bits

The number of bits. For example, 64.

Return value type

bigint type.

Examples

Calculate the number of set bits in the binary representation of 24:

  • Query statement

    * | SELECT bit_count(24, 64)
  • The query returns 2.

bitwise_and

Performs a bitwise AND operation on x and y.

Syntax

bitwise_and(x, y)

Parameters

Parameter

Description

x

A bigint value.

y

A bigint value.

Return value type

bigint type.

Examples

Perform a bitwise AND operation on 3 and 5:

  • Query statement

    * | SELECT bitwise_and(3, 5)
  • The query returns 1 in the _col0 column.

bitwise_not

Performs a bitwise NOT operation on x.

Syntax

bitwise_not(x)

Parameters

Parameter

Description

x

A bigint value.

Return value type

bigint type.

Examples

Perform a bitwise NOT operation on 4:

  • Query statement

    * | SELECT bitwise_not(4)
  • The query returns -5 in the _col0 column.

bitwise_or

Performs a bitwise OR operation on x and y.

Syntax

bitwise_or(x, y)

Parameters

Parameter

Description

x

A bigint value.

y

A bigint value.

Return value type

bigint type.

Examples

Perform a bitwise OR operation on 3 and 5:

  • Query statement

    * | SELECT bitwise_or(3, 5)
  • The query returns 7.

bitwise_xor

Performs a bitwise XOR operation on x and y.

Syntax

bitwise_xor(x, y)

Parameters

Parameter

Description

x

A bigint value.

y

A bigint value.

Return value type

bigint type.

Examples

Perform a bitwise XOR operation on 3 and 5:

  • Query statement

    * | SELECT bitwise_xor(3, 5)
  • The query returns 6.