[comment]: # attributes: notoc

[comment]: # translation:outdated

[comment]: # ({9e01c200-ca911365})
# 2 Funções bit a bit

Todas as funções listadas aqui são suportadas em:

- [Expressões de gatilho](/manual/config/triggers/expression)
- [Itens calculados](/manual/config/items/itemtypes/calculated)

Algumas notas gerais sobre parâmetros de função:

- Os parâmetros da função são separados por uma vírgula
- Expressões são aceitas como parâmetros
- Parâmetros de função opcionais (ou partes de parâmetros) são indicados por
    `<` `>`

|FUNÇÃO|<|<|<|
|--------|-|-|-|
|<|**Descrição**|**Parâmetros específicos da função**|**Comentários**|
|**bitand** (valor,máscara)|<|<|<|
|<|Valor de "E bit a bit" de um valor de item e máscara.|**valor** - valor a ser verificado<br>**máscara** (obrigatório) - inteiro sem sinal de 64 bits (0 - 18446744073709551615)|Suportado tipos de valor: int<br><br>Embora a comparação seja feita de forma bit a bit, todos os valores devem ser fornecidos e retornados em decimal. Por exemplo, a verificação do 3º bit é feita comparando-se a 4, não a 100.<br><br>Exemplos:<br>=> **bitand**(last(/host/key),**12** )=8 ou **bitand**(last(/host/key),**12**)=4 → 3º ou 4º bit definido, mas não ambos ao mesmo tempo<br>=> **bitand** (last(/host/key),**20**)=16 → 3º bit não definido e 5º bit definido.|
|**bitlshift** (valor, bits para deslocamento)|<|<|<|
|<|Deslocamento bit a bit para a esquerda de um valor de item.|**valor** - valor a ser verificado<br>**bits para deslocamento** (obrigatório) - número de bits para deslocamento|Tipos de valor suportados: int<br>< br>Embora a comparação seja feita de forma bit a bit, todos os valores devem ser fornecidos e são retornados em decimal. Por exemplo, a verificação do 3º bit é feita comparando-se a 4, não a 100.|
|**bitnot** (valor)|<|<|<|
|<|Valor de "NÃO bit a bit" de um valor de item.|**valor** - valor a ser verificado<br>|Tipos de valor suportados: int<br><br>Embora a comparação seja feita de maneira bit a bit, todos os valores devem ser fornecidos e são retornados em decimal. Por exemplo, a verificação do 3º bit é feita comparando-se a 4, não a 100.|
|**bitor** (valor,máscara)|<|<|<|
|<|Valor de "OR bit a bit" de um valor de item e máscara.|**valor** - valor a ser verificado<br>**máscara** (obrigatório) - inteiro sem sinal de 64 bits (0 - 18446744073709551615)|Suportado tipos de valor: int<br><br>Embora a comparação seja feita de forma bit a bit, todos os valores devem ser fornecidos e retornados em decimal. Por exemplo, a verificação do 3º bit é feita comparando-se a 4, não a 100.|
|**bitrshift** (valor, bits para deslocamento)|<|<|<|
|<|Deslocamento bit a bit para a direita de um valor de item.|**valor** - valor a ser verificado<br>**bits a serem deslocados** (obrigatório) - número de bits a serem deslocados|Tipos de valor suportados: int<br>< br>Embora a comparação seja feita de forma bit a bit, todos os valores devem ser fornecidos e são retornados em decimal. Por exemplo, a verificação do 3º bit é feita comparando-se a 4, não a 100.|
|**bitxor** (valor,máscara)|<|<|<|
|<|Valor de "OR exclusivo bit a bit" de um valor de item e máscara.|**valor** - valor a ser verificado<br>**máscara** (obrigatório) - inteiro sem sinal de 64 bits (0 - 18446744073709551615)| Tipos de valores suportados: int<br><br>Embora a comparação seja feita de forma bit a bit, todos os valores devem ser fornecidos e são retornados em decimal. Por exemplo, a verificação do 3º bit é feita comparando-se a 4, não a 100.|

[comment]: # ({/9e01c200-ca911365})

[comment]: # ({new-80c8d9ba})
### 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
    `<` `>`

[comment]: # ({/new-80c8d9ba})

[comment]: # ({new-ba090b44})

##### bitand(value,mask) {#bitand}

The value of "bitwise AND" of an item value and mask.<br>
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

[comment]: # ({/new-ba090b44})

[comment]: # ({new-5b5c2f3e})

##### bitlshift(value,bits to shift) {#bitlshift}

The bitwise shift left of an item value.<br>
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.

[comment]: # ({/new-5b5c2f3e})

[comment]: # ({new-ac54222f})

##### bitnot(value) {#bitnot}

The value of "bitwise NOT" of an item value.<br>
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.

[comment]: # ({/new-ac54222f})

[comment]: # ({new-e0357d53})

##### bitor(value,mask) {#bitor}

The value of "bitwise OR" of an item value and mask.<br>
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.

[comment]: # ({/new-e0357d53})

[comment]: # ({new-2fbc8601})

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

The bitwise shift right of an item value.<br>
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.

[comment]: # ({/new-2fbc8601})

[comment]: # ({new-2d663611})

##### bitxor(value,mask) {#bitxor}

The value of "bitwise exclusive OR" of an item value and mask.<br>
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.

[comment]: # ({/new-2d663611})

[comment]: # ({new-540c5e03})

See [all supported functions](/manual/appendix/functions).

[comment]: # ({/new-540c5e03})
