Documentation Index
Fetch the complete documentation index at: https://private-7c7dfe99-page-updates.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Bit functions
Bit functions work for any pair of types fromUInt8, UInt16, UInt32, UInt64, Int8, Int16, Int32, Int64, Float32, or Float64. Some functions support String and FixedString types.
The result type is an integer with bits equal to the maximum bits of its arguments. If at least one of the arguments is signed, the result is a signed number. If an argument is a floating-point number, it is cast to Int64.
bitAnd
Introduced in: v1.1.0 Performs bitwise AND operation between two values. Syntaxa AND b
Examples
Usage example
Query
Response
bitCount
Introduced in: v20.3.0 Calculates the number of bits set to one in the binary representation of a number. Syntaxx. UInt8.
The function does not convert the input value to a larger type (sign extension).
For example:
bitCount(toUInt8(-1)) = 8.Query
Response
bitHammingDistance
Introduced in: v21.1.0 Returns the Hamming Distance between the bit representations of two numbers. Can be used withSimHash functions for detection of semi-duplicate strings.
The smaller the distance, the more similar the strings are.
Syntax
x— First number for Hamming distance calculation.(U)Int*orFloat*y— Second number for Hamming distance calculation.(U)Int*orFloat*
x and y UInt8
Examples
Usage example
Query
Response
bitNot
Introduced in: v1.1.0 Performs the bitwise NOT operation. Syntax~a i.e a with bits flipped.
Examples
Usage example
Query
Response
bitOr
Introduced in: v1.1.0 Performs bitwise OR operation between two values. Syntaxa OR b
Examples
Usage example
Query
Response
bitRotateLeft
Introduced in: v1.1.0 Rotate bits left by a certain number of positions. Bits that fall off wrap around to the right. Syntaxa— A value to rotate.(U)Int8/16/32/64N— The number of positions to rotate left.UInt8/16/32/64
a. (U)Int8/16/32/64
Examples
Usage example
Query
Response
bitRotateRight
Introduced in: v1.1.0 Rotate bits right by a certain number of positions. Bits that fall off wrap around to the left. Syntaxa— A value to rotate.(U)Int8/16/32/64N— The number of positions to rotate right.UInt8/16/32/64
a. (U)Int8/16/32/64
Examples
Usage example
Query
Response
bitShiftLeft
Introduced in: v1.1.0 Shifts the binary representation of a value to the left by a specified number of bit positions. AFixedString or a String is treated as a single multibyte value.
Bits of a FixedString value are lost as they are shifted out.
On the contrary, a String value is extended with additional bytes, so no bits are lost.
Syntax
a— A value to shift.(U)Int*orStringorFixedStringN— The number of positions to shift.UInt8/16/32/64
a.
Examples
Usage example with binary encoding
Query
Response
Query
Response
Query
Response
bitShiftRight
Introduced in: v1.1.0 Shifts the binary representation of a value to the right by a specified number of bit positions. AFixedString or a String is treated as a single multibyte value.
Bits of a FixedString value are lost as they are shifted out.
On the contrary, a String value is extended with additional bytes, so no bits are lost.
Syntax
a— A value to shift.(U)Int*orStringorFixedStringN— The number of positions to shift.UInt8/16/32/64
a.
Examples
Usage example with binary encoding
Query
Response
Query
Response
Query
Response
bitSlice
Introduced in: v22.2.0 Returns a substring starting with the bit from the ‘offset’ index that is ‘length’ bits long. Syntax-
s— The String or Fixed String to slice.StringorFixedString -
offset— Returns the starting bit position (1-based indexing). - Positive values: count from the beginning of the string.
-
Negative values: count from the end of the string.
(U)Int8/16/32/64orFloat* -
length— Optional. The number of bits to extract. -
Positive values: extract
lengthbits. -
Negative values: extract from the offset to
(string_length - |length|). - Omitted: extract from offset to end of string.
-
If length is not a multiple of 8, the result is padded with zeros on the right.
(U)Int8/16/32/64orFloat*
String
Examples
Usage example
Query
Response
bitTest
Introduced in: v1.1.0 Takes any number and converts it into binary form, then returns the value of the bit at a specified position. Counting is done right-to-left, starting at 0. Syntaxa— Number to convert.(U)Int8/16/32/64orFloat*i— Position of the bit to return.(U)Int8/16/32/64orFloat*
i in the binary representation of a UInt8
Examples
Usage example
Query
Response
bitTestAll
Introduced in: v1.1.0 Returns result of the logical conjunction (AND operator) of all bits at the given positions. Counts right-to-left, starting at 0. The logical AND between two bits is true if and only if both input bits are true. Syntaxa— An integer value.(U)Int8/16/32/64index1, ...— One or multiple positions of bits.(U)Int8/16/32/64
UInt8
Examples
Usage example 1
Query
Response
Query
Response
bitTestAny
Introduced in: v1.1.0 Returns result of the logical disjunction (OR operator) of all bits at the given positions in a number. Counts right-to-left, starting at 0. The logical OR between two bits is true if at least one of the input bits is true. Syntaxa— An integer value.(U)Int8/16/32/64index1, ...— One or multiple positions of bits.(U)Int8/16/32/64
UInt8
Examples
Usage example 1
Query
Response
Query
Response
bitXor
Introduced in: v1.1.0 Performs bitwise exclusive or (XOR) operation between two values. Syntaxa XOR b
Examples
Usage example
Query
Response