Module Safe_int


module Safe_int: Extlib.ExtInt.Safe_int
Safe operations on integers.

This module provides operations on the type int of integers. Values of this type may be either 31 bits on 32-bit processors or 63 bits on 64-bit processors. Operations which overflow raise exception Numeric.Overflow.

This module implements Numeric.Numeric, Numeric.Bounded, Numeric.Discrete.

Important note Untested.


type t = int 
An alias for the type of integers.
val zero : t
The integer 0.
val one : t
The integer 1.
val minus_one : t
The integer -1.
val neg : t -> t
Unary negation.
val add : t ->
t -> t
Addition.
val (+) : t ->
t -> t
Addition.
val sub : t ->
t -> t
Subtraction.
val (-) : t ->
t -> t
Subtraction.
val mul : t ->
t -> t
Multiplication.
val ( * ) : t ->
t -> t
Multiplication.
val div : t ->
t -> t
Integer division. Raise Division_by_zero if the second argument is zero. This division rounds the real quotient of its arguments towards zero, as specified for Standard.(/).
val (/) : t ->
t -> t
Integer division. Raise Division_by_zero if the second argument is zero. This division rounds the real quotient of its arguments towards zero, as specified for Standard.(/).
val rem : t ->
t -> t
Integer remainder. If y is not zero, the result of Int.rem x y satisfies the following property: x = Int.add (Int.mul (Int.div x y) y) (Int.rem x y). If y = 0, Int.rem x y raises Division_by_zero.
val modulo : t ->
t -> t
modulo a b computes the remainder of the integer division of a by b. This is defined only if b <> 0.

The result of modulo a b is a number m between 0 and abs ( b - 1 ) if a >= 0 or between ~- ( abs ( b - 1 ) ) if a < 0 and such that a * k + (abs b) = m, for some k.

val pow : t ->
t -> t
pow a b computes ab
val ( ** ) : t ->
t -> t
a ** b computes ab
val (<>) : t -> t -> bool
val (>) : t -> t -> bool
val (<) : t -> t -> bool
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (=) : t -> t -> bool
val min_num : t
The greatest representable integer, which is either 230-1 or 262-1.
val max_num : t
The smallest representable integer, -230 or 262.
val succ : t -> t
Successor. succ x is add x one.
val pred : t -> t
Predecessor. pred x is sub x one.
val abs : t -> t
Return the absolute value of its argument.
val of_float : float -> t
Convert the given floating-point number to integer integer, discarding the fractional part (truncate towards 0). The result of the conversion is undefined if, after truncation, the number is outside the range [Int.min_int, Int.max_int].
val to_float : t -> float
Convert the given integer to a floating-point number.
val of_string : string -> t
Convert the given string to an integer The string is read in decimal (by default) or in hexadecimal, octal or binary if the string begins with 0x, 0o or 0b respectively. Raise Invalid_argument "int_of_string" if the given string is not a valid representation of an integer, or if the integer represented exceeds the range of integers representable in type int.
val to_string : t -> string
Return the string representation of its argument, in signed decimal.
val compare : t -> t -> int
The comparison function for integers, with the same specification as Standard.compare. Along with the type t, this function compare allows the module Int to be passed as argument to the functors Set.Make and Map.Make.
val operations : t Numeric.numeric
val of_int : int -> t
val to_int : t -> int

Boilerplate code


S-Expressions

val t_of_sexp : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t
val print : 'a Extlib.InnerIO.output -> t -> unit
Printing