bytes
bit_pos_to_byte_pos (UDF)
Given a bit position, get the byte that bit appears in. 1-indexed (to match substr), and accepts negative values.
Parameters
INPUTS
bit_pos INT64
OUTPUTS
INT64
extract_bits (UDF)
Extract bits from a byte array. Roughly matches substr with three arguments: b: bytes - The byte string we need to extract from start: int - The position of the first bit we want to extract. Can be negative to start from the end of the byte array. One-indexed, like substring. length: int - The number of bits we want to extract
The return byte array will have CEIL(length/8) bytes. The bits of interest will start at the beginning of the byte string. In other words, the byte array will have trailing 0s for any non-relevant fields.
Examples: bytes.extract_bits(b'\x0F\xF0', 5, 8) = b'\xFF' bytes.extract_bits(b'\x0C\xC0', -12, 8) = b'\xCC'
Parameters
INPUTS
b BYTES, `begin` INT64, length INT64
OUTPUTS
BYTES
zero_right (UDF)
Zero bits on the right of byte
Parameters
INPUTS
b BYTES, length INT64
OUTPUTS
BYTES