All Products
Search
Document Center

Simple Log Service:Bitwise functions

Last Updated:Sep 03, 2024

This topic describes the syntax of bitwise functions. This topic also provides examples on how to use the functions.

The following table describes the bitwise functions that are supported by Simple Log Service.

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

Syntax

Description

Supported in SQL

Supported in SPL

bit_count function

bit_count(x, bits)

Returns the number of bits 1 in x in binary representation.

bitwise_and function

bitwise_and(x, y)

Returns the result of the bitwise AND operation on x and y in binary representation.

bitwise_not function

bitwise_not(x)

Returns the result of the bitwise NOT operation on x in binary representation.

bitwise_or function

bitwise_or(x, y)

Returns the result of the bitwise OR operation on x and y in binary representation.

bitwise_xor function

bitwise_xor(x, y)

Returns the result of the bitwise XOR operation on x and y in binary representation.

bit_count function

The bit_count function returns the number of bits 1 in x in binary representation.

Syntax

bit_count(x, bits)

Parameters

Parameter

Description

x

The value of this parameter is of the bigint type.

bits

This parameter specifies the number of bits, such as 64 bits.

Return value type

The bigint type.

Examples

Convert the number 24 into a binary number and obtain the number of bits 1 in the binary number.

  • Query statement

    * | SELECT bit_count(24, 64)
  • Query and analysis resultsbit_count

bitwise_and function

The bitwise_and function returns the result of the bitwise AND operation on x and y in binary representation.

Syntax

bitwise_and(x, y)

Parameters

Parameter

Description

x

The value of this parameter is of the bigint type.

y

The value of this parameter is of the bigint type.

Return value type

The bigint type.

Examples

Perform a bitwise AND operation on 3 and 5 in binary representation.

  • Query statement

    * | SELECT bitwise_and(3, 5)
  • Query and analysis resultsbitwise_and

bitwise_not function

The bitwise_not function returns the result of the bitwise NOT operation on x in binary representation.

Syntax

bitwise_not(x)

Parameters

Parameter

Description

x

The value of this parameter is of the bigint type.

Return value type

The bigint type.

Examples

Perform a bitwise NOT operation on 4 in binary representation.

  • Query statement

    * | SELECT bitwise_not(4)
  • Query and analysis resultsbitwise_not

bitwise_or function

The bitwise_or function returns the result of the bitwise OR operation on x and y in binary representation.

Syntax

bitwise_or(x, y)

Parameters

Parameter

Description

x

The value of this parameter is of the bigint type.

y

The value of this parameter is of the bigint type.

Return value type

The bigint type.

Examples

Perform a bitwise OR operation on 3 and 5 in binary representation.

  • Query statement

    * | SELECT bitwise_or(3, 5)
  • Query and analysis resultsbitwise_or

bitwise_xor function

The bitwise_xor function returns the result of the bitwise XOR operation on x and y in binary representation.

Syntax

bitwise_xor(x, y)

Parameters

Parameter

Description

x

The value of this parameter is of the bigint type.

y

The value of this parameter is of the bigint type.

Return value type

The bigint type.

Examples

Perform a bitwise XOR operation on 3 and 5 in binary representation.

  • Query statement

    ?1* | SELECT bitwise_xor(3, 5)
  • Query and analysis resultsbitwise_xor