package checked_oint

  1. Overview
  2. Docs
An OCaml library for checked integer arithmetic

Install

Dune Dependency

Authors

Maintainers

Sources

checked_oint-0.6.0.tar.gz
md5=b591d7b273ed7b077bfcf9e6c18b8b0f
sha512=011068d5af060e4e9b5e72631e61967e4566c80271bd42ff93b2bd65b79dbe8360058ebeb184e3a6582c6aa4da48d65c390dc87e04883bf3ff7d5fa600354a3c

doc/README.html

checked_oint

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.

Installation

$ opam install checked_oint

Usage

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.

Implementation

  • u8, u16, i8, and i16 are represented as int internally.
  • u32 and i32 (resp. u64 and i64) are represented as int32 (resp. int64) internally.
  • u128 and i128 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.

Release procedure

  1. Update the version field in dune-project.
  2. Type dune build to generate checked_oint.opam.
  3. Update CHANGELOG.md.
  4. Release the project in GitHub Releases.

    1. Generate a source code archive and include it in the release:
      git archive HEAD -o checked_oint-<major>.<minor>.<patch>.tar.gz
  5. Type git pull && opam publish.

    1. Specify the correct archive URL and checksums (by running md5sum and sha512sum on the archive).
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.

OCaml

Innovation. Community. Security.