package checked_oint
Library
Module
Module type
Parameter
Class
Class type
A single integer of an arbitrary type.
This module is useful for typed manipulation of an integer value, which can belong to any integer type. A first-class instance of this module can be obtained by calling singleton
with a generic
integer.
include S with type t := t
val equal : t -> t -> Ppx_deriving_runtime.bool
val pp :
Ppx_deriving_runtime.Format.formatter ->
t ->
Ppx_deriving_runtime.unit
val show : t -> Ppx_deriving_runtime.string
val compare : t -> t -> Ppx_deriving_runtime.int
val int_ty : int_ty
The type representation.
val zero : t
The value of 0.
val one : t
The value of 1.
val all_ones : t
The value that has all bits set to 1.
val min_int : t
The minimum value of this type.
val max_int : t
The maximum value of this type.
val of_int : int -> t option
Constructs a value out of int
; returns None
on overflow/underflow.
val of_string : string -> t option
Constructs a value out of string
; returns None
on overflow/underflow.
We allow the following classes of non-negative integers:
- Binary:
0b
(0B
) followed by a non-empty sequence of binary digits0
and1
. - Octal:
0o
(0O
) followed by a non-empty sequence of octal digits0
, ...,7
. - Decimal: a non-empty sequence of decimal digits
0
, ...,9
. - Hexadecimal:
0x
(0X
) followed by a non-empty sequence of decimal digits0
, ...,9
and lettersa
, ...,f
(A
, ...,F
).
(Currently, 128-bit integers can only be decimal.)
A negative integer is described by the -
character followed by a well-formed non-negative integer.
All other combinations of characters will return None
.
Performs right shifting; returns None
on overflow/underflow.
This is a logical shift for unsigned integer types and arithmetic shift for signed integer types.
val of_int_exn : int -> t
Same as of_int
but raises Out_of_range
instead of returning None
.
val of_string_exn : string -> t
Same as of_string
but raises Out_of_range
instead of returning None
.
Finds a successor; raises Out_of_range
on overflow.
Finds a predecessor; raises Out_of_range
on underflow.
Performs unary negation; raises Out_of_range
on overflow/underflow.
Finds an absolute value; raises Out_of_range
on overflow.
Performs addition; raises Out_of_range
on overflow/underflow.
Performs subtraction; raises Out_of_range
on overflow/underflow.
Performs multiplication; raises Out_of_range
on overflow/underflow.
Performs division; raises Out_of_range
on overflow/underflow.
Finds a remainder; raises Out_of_range
on overflow/underflow.
Performs left shifting; raises Out_of_range
on overflow/underflow.
Performs right shifting; raises Out_of_range
on overflow/underflow.
This is a logical shift for unsigned integer types and arithmetic shift for signed integer types.
val value : t