FirebirdSQL logo

BIN_NOT()

Bitwise NOT

Result type

integer type matching the argument

Note

SMALLINT result is returned only if all the arguments are explicit SMALLINTs or NUMERIC(n, 0) with n <= 4;otherwise small integers return an INTEGER result.

Syntax
BIN_NOT (number)
Table 1. BIN_NOT Function Parameter
Parameter Description

number

A number of an integer type

Returns the result of the bitwise NOT operation on the argument, i.e. one’s complement.

BIN_OR()

Bitwise OR

Result type

integer type (the widest type of the arguments)

Note

SMALLINT result is returned only if all the arguments are explicit SMALLINTs or NUMERIC(n, 0) with n <= 4;otherwise small integers return an INTEGER result.

Syntax
BIN_OR (number, number [, number ...])
Table 1. BIN_OR Function Parameters
Parameter Description

number

A number of an integer type

Returns the result of the bitwise OR operation on the argument(s).

BIN_SHL()

Bitwise left-shift

Result type

BIGINT or INT128 depending on the first argument

Syntax
BIN_SHL (number, shift)
Table 1. BIN_SHL Function Parameters
Parameter Description

number

A number of an integer type

shift

The number of bits the number value is shifted by

Returns the first argument bitwise left-shifted by the second argument, i.e. a << b or a·2b.

BIN_SHR()

Bitwise right-shift with sign extension

Result type

BIGINT or INT128 depending on the first argument

Syntax
BIN_SHR (number, shift)
Table 1. BIN_SHR Function Parameters
Parameter Description

number

A number of an integer type

shift

The number of bits the number value is shifted by

Returns the first argument bitwise right-shifted by the second argument, i.e. a >> b or a/2b.

The operation performed is an arithmetic right shift (x86 SAR), meaning that the sign of the first operand is always preserved.