Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Bitlib 0️⃣1️⃣0️⃣1️⃣
A simple OCaml library for bit/byte operations. The purpose of this library is to provide aid to users writing binary files, NOT perform bitwise operations on objects in memory.
Examples
Getting the binary representation of a number.
to_bits 5 // returns [1;0;1]
Ensuring a binary sequence is of a certain length, e.g. 8 or 64 bits.
// Write a short int (2 bytes) to a binary file
let bits = to_bits 512 in
let padded = pad 16 bits in
let bytes = to_bytes padded 2 in
write_binary_file bytes "output.byte"