Module BatInt


module BatInt: sig .. end
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. 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


type t = int 
An alias for the type of integers.
val zero : int
The integer 0.
val one : int
The integer 1.
val minus_one : int
The integer -1.
val neg : int -> int
Unary negation.
val add : int -> int -> int
Addition.
val (+) : int -> int -> int
Addition.
val sub : int -> int -> int
Subtraction.
val (-) : int -> int -> int
Subtraction.
val mul : int -> int -> int
Multiplication.
val ( * ) : int -> int -> int
Multiplication.
val div : int -> int -> int
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 Pervasives.(/).
val (/) : int -> int -> int
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 Pervasives.(/).
val rem : int -> int -> int
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 : 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
val ( ** ) : int -> int -> int
a ** b computes ab
val (<>) : 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
The greatest representable integer, which is either 230-1 or 262-1.
val max_num : int
The smallest representable integer, -230 or 262.
val succ : int -> int
Successor. Int.succ x is Int.add x Int.one.
val pred : int -> int
Predecessor. Int.pred x is Int.sub x Int.one.
val abs : int -> int
Return the absolute value of its argument.
val of_float : float -> int
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 : int -> float
Convert the given integer to a floating-point number.
val of_string : string -> int
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 : int -> 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 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 operations : int BatNumber.numeric
val (--) : t -> t -> t BatEnum.t
Enumerate an interval.

5 -- 10 is the enumeration 5,6,7,8,9,10. 10 -- 5 is the empty enumeration

val (---) : t -> t -> t BatEnum.t
Enumerate an interval.

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

Submodules regrouping all infix operations

module Infix: BatNumber.Infix  with type bat__infix_t = t
module Compare: BatNumber.Compare  with type bat__compare_t = t

Boilerplate code


Printing

val print : 'a BatInnerIO.output -> int -> unit
val xprint : 'a BatInnerIO.output -> int -> unit
prints as hex string
val t_printer : t BatValue_printer.t
module Safe_int: sig .. end
Safe operations on integers.