Library
Module
Module type
Parameter
Class
Class type
to_bits i
: Converts an integer, i
, to a list of bits.
For example, to_bits 5 => [1;0;1]
pad padding bits
: Ensures bits is of length padding
, left-padding the list with 0's as needed.
For example, padding 8 [1;0;1] => [0;0;0;0;0;1;0;1]
to_bytes bits n
: Writes the bit sequence, bits
, as a byte sequence of n
length. Assumes bytes are 8 bits.
For example, to_bytes (padding 32 (to_bits 256)) 4 => [0;0;1;0]
or to_bytes [0;0;0;0;0;1;0;1] 1 => [5]
little_endian_of_int i bytes
: converts an integer, i
, to a list of bytes in little endian order.
For example, little_endian_of_int 5 2 => [0;5]
big_endian_of_int i bytes
: converts an integer, i
, to a list of bytes in big endian order.
For example, big_endian_of_int 5 2 => [5;0]