bin_decode() reads n consecutive values of one type from the raw
vector x, starting at the 0-based byte offset:
bin_decode(x, "u32", offset = 4) is a header field,
bin_decode(x, "f32", offset = 64, n = 1e6) is a column. It is
readBin() generalised to every width and both byte orders, exact or an
error; bin_encode() is its inverse. Offsets are 0-based.
Arguments
- x
A raw vector.
- type
Any type token of
bin_layout()except padding ("u8","i128","f16","c64","bool","b16","s8", ...), optionally with a.leor.besuffix.- offset
The 0-based byte position of the first record.
- n
The number of values, or
NULLfor every whole value that fits.- endian
The byte order:
"little","big", or"native".- int64
How
i64,u64,i128andu128fields are returned:"double", exact or an error; or"integer64", a double vector carrying the 64-bit pattern with classinteger64, as the bit64 package defines it.- na
"error", or"allow"to read -2^31 in ani32field asNA_integer_(and -2^63 ininteger64mode asNA).
Value
A vector of the type's R type (see bin_layout()): integer,
double, integer64, complex, logical, character, or a list of raw
vectors for b<n>.