Binary data
BINARY
binary(Vector of Integer v
) -> Binary
STABLE
Convert v
to byte array
binary(Charstring hex
) -> Binary
STABLE
Convert hexadecimal string hex
to binary object
binary(Integer i
) -> Binary
STABLE
Convert integer i
to binary object
BITREVERSE
bitreverse(Binary b
) -> Binary
STABLE
Reverse bit order in binary object b
CHARSTRING
charstring(Binary b
) -> Charstring
STABLE
Extract string of bytes from binary object b
DIM
dim(Binary b
) -> Integer
STABLE
The number of bytes in binary object 'b'
dim(Memory m
) -> Integer
STABLE
The number of bytes in byte array m
FPACK
fpack(Vector data
, Charstring frm
) -> Integer
STABLE
The inverse of funpack
. Put the data in the vector data
into
a bitpacked Integer according to the format string `frm`.
The same format string conventions apply.
FUNPACK
funpack(Binary bin
, Charstring frm
) -> Vector
STABLE
No description.
funpack(Integer d
, Charstring frm
) -> Vector
STABLE
Unpack integer d
based on format frm
.
`frm` is the format string `([IiUuFfZz][0-9]*)*`.
For example: `"u8z4i4"`
`u8` -> Read 8 bits as an unsigned integer.
`z4` -> Skip the next 4 bits.
`i4` -> Read the next 4 bits as a signed integer.
`f8` -> Read the next 8 bits as a floating point.
Upper case means read as big-endian, lower case is little-endian.
Endianess must match for all fields. For example, with "U8Z8I16",
`d` will be converted as one byte and one big-endian 16-bit signed
integer, with a skipped 8-bit space in-between. Floating point
formats other than 32- or 64-bit requires an unpacker defined using
`unpack_ieee` as a template.
F_BITS
f_bits(Integer i
, Integer pos
, Integer w
) -> Real
STABLE
Get floating point bit field of width 'w' at offset 'pos' in 'i'.
f_bits(Binary bin
, Integer pos
, Integer w
) -> Real
STABLE
Extract a floating point from bin
. Formats other than
32- or 64-bit floats require a specialization of `unpack_ieee`.
For example, to unpack 8-bit mini-floats, use
`create function unpack_float8(Integer d)->Real as unpack_ieee(d,4,3);`
HEX
hex(Binary b
) -> Charstring
STABLE
Convert binary object b
to hexadecimal string
HEX2INTEGER
hex2integer(Charstring hexnum
) -> Integer
STABLE
Convert hexadecimal number hexnum
to corresponding integer
IN
in(Binary b
) -> Bag of Integer
STABLE
The elements of byte array b
in(Memory m
) -> Bag of Integer
STABLE
The elements of byte array in m
INTEGER
integer(Binary b
) -> Integer
STABLE
Convert binary object b
to integer
INTEGER2HEX
integer2hex(Integer i
) -> Charstring
STABLE
Convert integer i
to the corresponding hexadecimal number
MAKE_BINARY
make_binary(Integer sz
) -> Binary
STABLE
Construct a new binary object with 'sz' bytes
NEW_MEMORY
new_memory(Integer s
) -> Memory
STABLE
Create new Memory object of size s
PACK_IEEE
pack_ieee(Real x
, Integer e_bits
, Integer m_bits
) -> Integer d
STABLE
Pack a real x
as an IEEE754-like integer bit field with a format
specified by `e_bits` exponent bits and `m_bits` mantissa bits. For
example, to make an 8-bit representation of Real numbers, define
`create function pack_float8(Real x)->Integer as pack_ieee(x,4,3);`
This function supports NaN, �Infinity and subnormal numbers. The sign
bit counts as one, so for an N-bit format, `e_bits` and `m_bits` should
sum to N-1.
RAW_FILE
raw_file(Charstring path
) -> Memory
STABLE
No description.
REAL_AS_INT
real_as_int(Real x
) -> Integer
STABLE
No description.
REQUEST_ID
request_id( ) -> Charstring
STABLE
No description.
SECTION
section(Binary b
, Integer l
, Integer u
) -> Binary
STABLE
Elements from position l
to u
in binary object b
SETF
setf(Binary b
, Integer i
, Integer v
)
STABLE
Set byte i
in binary object b
to v
setf(Memory m
, Integer i
, Integer v
)
STABLE
Set byte i
in byte array in m
to v
SKIP
skip(Binary b
, Integer n
) -> Binary
STABLE
Skip first n
elements in binary object b
S_BITS
s_bits(Integer i
, Integer pos
, Integer w
) -> Integer
STABLE
Get signed bit field of width 'w' at offset 'pos' in 'i'.
s_bits(Binary bin
, Integer pos
, Integer w
) -> Integer
STABLE
Extract from bin
a sign exended (2-complement) Integer at bit
position `pos` of width `w`.
UNPACK
unpack(Binary b
, Charstring frm
) -> Vector of Integer
DEPRECATED
Unpack binary object b
based on format frm
.
This was deprecated in version 5.6.11.
Use funpack(b, frm)
unpack(Charstring hex
, Charstring frm
) -> Vector of Integer
DEPRECATED
Unpack hexadecimal string hex
based on format frm
.
`frm` is a string with format specifications `[IiUuZz][0-9][0-9]+`.
Examples:
I32 -> Read the next 32 bits as a signed integer.
u16 -> Read the next 16 bits as an unsigned integer.
Z08 -> Skip the next 8 bits.
This was deprecated in version 5.6.11.
Use funpack(binary(hex), frm)
UNPACK_IEEE
unpack_ieee(Integer d
, Integer e_bits
, Integer m_bits
) -> Real
STABLE
Unpack a binary floating point format from an Integer d
with one sign
bit, `e_bits` exponent bits, `m_bits` mantissa bits. Supports IEEE754
floats with Inf, NaN, and subnormal values, and an exponent bias of
2^(e_bits-1) - 1.
Specialize this function with constant e_bits and m_bits for use in
`funpack` and `f_bits`. This template cannot be used for formats with
zero mantissa bits.
An N-bit unpacker is automatically available from the `f_bits` and
`funpack` functions if named `unpack_floatN(Integer)->Real`. For example,
a `bfloat16` format unpacker may be defined as
`create function unpack_float16(Integer d)->Real as unpack_ieee(d,8,7);`
and would be used as the unpacker in `funpack(data,'f16f16');`
U_BITS
u_bits(Integer u
, Integer pos
, Integer w
) -> Integer
STABLE
Get unsigned bit field of width 'w' at offset 'pos' in 'u'.
u_bits(Binary bin
, Integer pos
, Integer w
) -> Integer
STABLE
Extract from bin
a zero exended Integer at bit position pos
of width `w`.
VREF
vref(Binary b
, Integer i
) -> Integer v
STABLE
Same as b[i]
to get byte i
in binary object b
vref(Memory m
, Integer i
) -> Integer
STABLE
Same as m[i]
vref(Tuple t
, Number i
) -> Object
STABLE
No description.