module Safe_int:sig..end
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 Number.Overflow.
This module implements Number.Numeric,
Number.Bounded, Number.Discrete.
Important note Untested.
typet =int
An alias for the type of integers.
val zero : tThe integer 0.
val one : tThe integer 1.
val minus_one : tThe integer -1.
val neg : t -> tUnary negation.
val add : t -> t -> tAddition.
val (+) : t -> t -> tAddition.
val sub : t -> t -> tSubtraction.
val (-) : t -> t -> tSubtraction.
val mul : t -> t -> tMultiplication.
val ( * ) : t -> t -> tMultiplication.
val div : t -> t -> tInteger division.
This division rounds the real quotient of
its arguments towards zero, as specified for Pervasives.(/).
Division_by_zero if the second argument is zero.val (/) : t -> t -> tInteger division. This division rounds the real quotient of
its arguments towards zero, as specified for Pervasives.(/).
Division_by_zero if the second argument is zero.val rem : t -> t -> tInteger 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).
Division_by_zero if the second argument is zero.val modulo : t -> t -> tmodulo 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 -> tpow a b computes ab.
Invalid_argument when b is negative.val ( ** ) : t -> t -> ta ** b computes ab
val (<>) : t -> t -> boolComparison: a <> b is true if and only if a and b have
different values.
val (>) : t -> t -> boolComparison: a > b is true if and only if a is strictly greater than b.
val (<) : t -> t -> boolComparison: a < b is true if and only if a is strictly smaller than b.
val (>=) : t -> t -> boolComparison: a >= b is true if and only if a is greater or equal to b.
val (<=) : t -> t -> boolComparison: a <= b is true if and only if a is smaller or equalto b.
val (=) : t -> t -> boolComparison: a = b if and only if a and b have the same value.
val max_num : tThe greatest representable integer, which is either 230-1 or 262-1.
val min_num : tThe smallest representable integer, -230 or 262.
val succ : t -> tSuccessor. succ x is add x one.
val pred : t -> tPredecessor. pred x is sub x one.
val abs : t -> tReturn the absolute value of its argument.
val of_float : float -> tConvert the given floating-point number to 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 -> floatConvert the given integer to a floating-point number.
val of_string : string -> tConvert 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.
Failure 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 -> stringReturn the string representation of its argument, in signed decimal.
val operations : t BatNumber.numeric
val of_int : int -> t
val to_int : t -> intmodule Infix:BatNumber.Infixwith type bat__infix_t = t
module Compare:BatNumber.Comparewith type bat__compare_t = t
val print : 'a BatInnerIO.output -> t -> unit
val compare : t -> t -> intThe comparison function for integers, with the same specification as
Pervasives.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 equal : t -> t -> boolEquality function for integers, useful for HashedType.
val ord : t -> t -> BatOrd.order