usane

Unsigned integers for OCaml

OTHER License

Stars
9

Usane - unsigned integers for OCaml

%%VERSION%% The behaviour of numbers (int, int32, int64) in OCaml is to be signed, and wrap around on over/underflow. This library gives explicit access to the carry bit by using compiler builtins. Other fine integer libraries, such as integers library and stdint) mirror the OCaml standard library behaviour.

This library defines 8, 16, 32, and 64 bit unsigned integers which interoperates well with the builtin types (int32, int64) by reusing their representation. Arithmetic operations return the carry bit explicitly.

Some motivating examples are:

# succ max_int
- : int = -4611686018427387904

# pred min_int
- : int = 4611686018427387903

# abs min_int
- : int = -4611686018427387904

Usane comes with a extensive test suite to show the behaviour.

Currently this library is not released, I first want to a) use ocb-stubblr (to get it to run on MirageOS) and b) test on 32bit.

Documentation

API Documentation is available online.