module BatInt:sig
..end
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. All arithmetic
operations over int
are taken modulo 2number of bits.
This module implements Number.Numeric
,
Number.Bounded
, Number.Discrete
.
Author(s): Gabriel Scherer, David Teller
typet =
int
val zero : int
0
.val one : int
1
.val minus_one : int
-1
.val neg : int -> int
val add : int -> int -> int
val (+) : int -> int -> int
val sub : int -> int -> int
val (-) : int -> int -> int
val mul : int -> int -> int
val ( * ) : int -> int -> int
val div : int -> int -> int
Pervasives.(/)
.Division_by_zero
if the second argument is zero.val (/) : int -> int -> int
Pervasives.(/)
.Division_by_zero
if the second argument is zero.val rem : int -> int -> int
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 : int -> int -> int
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 : int -> int -> int
pow a b
computes ab.Invalid_argument
when b
is negative.val ( ** ) : int -> int -> int
a ** b
computes abval (<>) : int -> int -> bool
val (>) : int -> int -> bool
val (<) : int -> int -> bool
val (>=) : int -> int -> bool
val (<=) : int -> int -> bool
val (=) : int -> int -> bool
val min_num : int
val max_num : int
val succ : int -> int
Int.succ x
is Int.add x Int.one
.val pred : int -> int
Int.pred x
is Int.sub x Int.one
.val abs : int -> int
min_num
. In that case, abs min_num = min_num
.val of_float : float -> int
Int.min_int
, Int.max_int
].val to_float : int -> float
val of_string : string -> int
0x
, 0o
or 0b
respectively.Invalid_argument
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 : int -> string
val min : int -> int -> int
min
from the
standard library.val max : int -> int -> int
min
from the
standard library.val mid : int -> int -> int
mid a b
returns floor((a+b)/2)
, but done
correctly to compensate for numeric overflows. The result is an
integer that lies between a
and b
and is as equidistant from
both as possible.val popcount : int -> int
val operations : int BatNumber.numeric
val (--) : t -> t -> t BatEnum.t
5 -- 10
is the enumeration 5,6,7,8,9,10.
10 -- 5
is the empty enumeration
val (---) : t -> t -> t BatEnum.t
5 --- 10
is the enumeration 5,6,7,8,9,10.
10 --- 5
is the enumeration 10,9,8,7,6,5.
val of_int : int -> int
val to_int : int -> int
module Infix:BatNumber.Infix
with type bat__infix_t = t
module Compare:BatNumber.Compare
with type bat__compare_t = t
val print : 'a BatInnerIO.output -> int -> unit
val print_hex : 'a BatInnerIO.output -> int -> unit
val compare : t -> t -> int
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 -> bool
HashedType
.val ord : t -> t -> BatOrd.order
module Safe_int:sig
..end