# 2 按位运算函数

• · 函数参数用逗号分隔
• · 接受表达式作为参数
• · 可选的函数参数（或参数部分）由 · `<` `>` 表示

Description 函数特定参数 注释
bitand (值,掩码)

=> bitand(last(/host/key),12 )=8 或 bitand(last(/host/key),12)=4 → 第 3 位或第 4 位设置，但不能同时设置
=> bitand (last(/host/key),20)=16 → 第 3 位未设置，第 5 位已设置。
bitlshift（值，要移动的位）

bitnot（值）

bitor（值，掩码）

bitrshift（值，要移动的位）

bitxor（值，掩码）

### Function details

Some general notes on function parameters:

• Function parameters are separated by a comma
• Expressions are accepted as parameters
• Optional function parameters (or parameter parts) are indicated by `<` `>`

The value of "bitwise AND" of an item value and mask.
Supported value types: Integer.

Parameter:

• value - the value to check;
• mask (mandatory) - a 64-bit unsigned integer (0 - 18446744073709551615).

Although the comparison is done in a bitwise manner, all the values must be supplied and are returned in decimal. For example, checking for the 3rd bit is done by comparing to 4, not 100.

Examples:

``````bitand(last(/host/key),12)=8 or bitand(last(/host/key),12)=4 #3rd or 4th bit set, but not both at the same time
bitand(last(/host/key),20)=16 #3rd bit not set and 5th bit set``````
##### bitlshift(value,bits to shift)

The bitwise shift left of an item value.
Supported value types: Integer.

Parameter:

• value - the value to check;
• bits to shift (mandatory) - the number of bits to shift.

Although the comparison is done in a bitwise manner, all the values must be supplied and are returned in decimal. For example, checking for the 3rd bit is done by comparing to 4, not 100.

##### bitnot(value)

The value of "bitwise NOT" of an item value.
Supported value types: Integer.

Parameter:

• value - the value to check.

Although the comparison is done in a bitwise manner, all the values must be supplied and are returned in decimal. For example, checking for the 3rd bit is done by comparing to 4, not 100.

The value of "bitwise OR" of an item value and mask.
Supported value types: Integer.

Parameter:

• value - the value to check;
• mask (mandatory) - a 64-bit unsigned integer (0 - 18446744073709551615).

Although the comparison is done in a bitwise manner, all the values must be supplied and are returned in decimal. For example, checking for the 3rd bit is done by comparing to 4, not 100.

##### bitrshift(value,bits to shift)

The bitwise shift right of an item value.
Supported value types: Integer.

Parameter:

• value - the value to check;
• bits to shift (mandatory) - the number of bits to shift.

Although the comparison is done in a bitwise manner, all the values must be supplied and are returned in decimal. For example, checking for the 3rd bit is done by comparing to 4, not 100.

The value of "bitwise exclusive OR" of an item value and mask.
Supported value types: Integer.

Parameter:

• value - the value to check;
• mask (mandatory) - a 64-bit unsigned integer (0 - 18446744073709551615).

Although the comparison is done in a bitwise manner, all the values must be supplied and are returned in decimal. For example, checking for the 3rd bit is done by comparing to 4, not 100.

<%= selection %>
To toggle search highlight, press Ctrl+Alt+H
Have an improvement suggestion for this page? Select the text that could be improved and press Ctrl+Enter to send it to the editors.
To toggle search highlight, press Command+Alt+H
Have an improvement suggestion for this page? Select the text that could be improved and press Command+Enter to send it to the editors.
Suggest an example