package bitlib
All checked builds passInstall
dune-project
Dependency
Authors
Maintainers
Sources
md5=35307eb5050cd336d9c6409ee74598cc
sha512=fb3e1757faa41ba3e6ccbb4cff504ead69b39199ee74ee119968118f0182cc5dad988c7bdf2d8a3c52e94ebf1bb1722698d57de00d4dae72837a96ca93d86eec
Description
Added to opam-repository:
README
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.
pad 8 (to_bits 5) // returns [0;0;0;0;0;1;0;1]Converting a bit sequence to a byte sequence.
to_bytes (pad 8 (to_bits 5)) 1 // returns [5]
to_bytes (padding 32 (to_bits 256)) 4 // returns [0;0;1;0]Allows you to generate byte sequences of any length in little or big endian order.
little_endian_of_int 255 2 // returns [0;255]
big_endian_of_int 255 2 // returns [255;0]Writing a sequence of bits to a binary file.
// 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"
Dependencies (1)
-
dune
>= "1.9"
Dev Dependencies (1)
-
alcotest
with-test
Optional Dependencies
None
Used by
None
Conflicts
None
Build status
Results of building bitlib with each compiler on check.ci.ocaml.org, run of against opam-repository 7cdc698. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 1.0 (this version) | good | good | good | good | good |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure