checked_oint
is an OCaml library for checked integer arithmetic. We support the full set of signed and unsigned integers of bitnesses 8, 16, 32, 64, and 128.
$ opam install checked_oint
open Checked_oint
let () =
let x = U8.of_int_exn 50 in
let y = U8.of_int_exn 70 in
assert (U8.equal (U8.add_exn x y) (U8.of_int_exn 120));
assert (Option.is_none (U8.mul x y))
You can find the API documentation here.
u8
,u16
,i8
, andi16
are represented asint
internally.u32
andi32
(resp.u64
andi64
) are represented asint32
(resp.int64
) internally.u128
andi128
are represented as{ high : int64; low : int64 }
internally.- Operations on integers of 8, 16, 32, and 64 bits are implemented primarily in OCaml, save a small amount of C stub functions.
- Operations on 128-bit integers are implemented solely in C.
- We heavily rely on the
__int128
extension by GCC and Clang.
- We heavily rely on the
- Update the
version
field indune-project
. - Type
dune build
to generatechecked_oint.opam
. - Update
CHANGELOG.md
. - Release the project in GitHub Releases.
- Generate a source code archive and include it in the release:
git archive HEAD -o checked_oint-<major>.<minor>.<patch>.tar.gz
- Generate a source code archive and include it in the release:
- Type
git pull && opam publish
.- Specify the correct archive URL and checksums (by running
md5sum
andsha512sum
on the archive).
- Specify the correct archive URL and checksums (by running
On the stability of source code archives
Including the output of git archive
is needed because GitHub does not guarantee stability of source code archives. With a static asset, we will always get the same checksum, which is crucial for packaging.