Z Convert Z to big endian Cstruct.t and generate random Z values.
of_cstruct_be ~bits cs interprets the bit pattern of
cs as a
t in big-endian.
~bits is not given, the operation considers the entire
cs, otherwise the initial
min ~bits (bit-length cs) bits of
n is the number of bits to extract, the
cs is always the least significant bit of the result. Therefore:
t is larger than
k - n most significant bits in the result are
k is smaller than
n, the result contains
k last of the
n first bits of
to_cstruct_be ~size t is the big-endian representation of
~size is not given, it defaults to the minimal number of bytes needed to represent
t, which is
bits t / 8 rounded up.
The least-significant bit of
t is always the last bit in the result. If the size is larger than needed, the output is padded with zero bits. If it is smaller, the high bits in
t are dropped.
into_cstruct_be t cs writes the big-endian representation of
cs. It behaves like
~size spanning the entire
gen ~g n picks a value in the interval
[0, n - 1] uniformly at random.