Module Checked_ointSource

checked_oint is an OCaml library for checked integer arithmetic.

This library supports signed and unsigned integers of bitnesses 8, 16, 32, 64, and 128. S is the main signature that contains common operations for all integer types; specific implementations are named U8, U16, and so on.

Polymorphic comparison operators raise Invalid_argument by default; use S.equal and S.compare instead. This behaviour is controlled by the checked_oint.guard virtual library; see the README.

Sourceexception Out_of_range

The exception raised on underflows/overflows.

Sourcetype u8

An unsigned 8-bit integer.

Sourceval compare_u8 : u8 -> u8 -> Ppx_deriving_runtime.int
Sourcetype u16

An unsigned 16-bit integer.

Sourceval compare_u16 : u16 -> u16 -> Ppx_deriving_runtime.int
Sourcetype u32

An unsigned 32-bit integer.

Sourceval compare_u32 : u32 -> u32 -> Ppx_deriving_runtime.int
Sourcetype u64

An unsigned 64-bit integer.

Sourceval compare_u64 : u64 -> u64 -> Ppx_deriving_runtime.int
Sourcetype u128

An unsigned 128-bit integer.

Sourceval compare_u128 : u128 -> u128 -> Ppx_deriving_runtime.int
Sourcetype i8

A signed 8-bit integer.

Sourceval compare_i8 : i8 -> i8 -> Ppx_deriving_runtime.int
Sourcetype i16

A signed 16-bit integer.

Sourceval compare_i16 : i16 -> i16 -> Ppx_deriving_runtime.int
Sourcetype i32

A signed 32-bit integer.

Sourceval compare_i32 : i32 -> i32 -> Ppx_deriving_runtime.int
Sourcetype i64

A signed 64-bit integer.

Sourceval compare_i64 : i64 -> i64 -> Ppx_deriving_runtime.int
Sourcetype i128

A signed 128-bit integer.

Sourceval compare_i128 : i128 -> i128 -> Ppx_deriving_runtime.int
Sourcemodule Int_ty : sig ... end

Represents a materialized integer type.

Sourcetype value =
  1. | Value : 'a Int_ty.t * 'a -> value

An integer of an arbitrary type.

Sourceval is_zero : value -> bool

true if the integer is 0, false otherwise.

Sourceval is_one : value -> bool

true if the integer is 1, false otherwise.

Sourceval is_all_ones : value -> bool

true if the integer has all bits set to 1, false otherwise.

Sourcemodule type S = sig ... end

The signature of operations on integers.

Sourcemodule U8 : S with type t = u8

The implementation of u8.

Sourcemodule U16 : S with type t = u16

The implementation of u16.

Sourcemodule U32 : S with type t = u32

The implementation of u32.

Sourcemodule U64 : S with type t = u64

The implementation of u64.

Sourcemodule U128 : sig ... end

The implementation of u128.

Sourcemodule I8 : S with type t = i8

The implementation of i8.

Sourcemodule I16 : S with type t = i16

The implementation of i16.

Sourcemodule I32 : S with type t = i32

The implementation of i32.

Sourcemodule I64 : S with type t = i64

The implementation of i64.

Sourcemodule I128 : sig ... end

The implementation of i128.

Sourceval ops : 'a Int_ty.t -> (module S with type t = 'a)

Finds an integer implementation based on its type representation.