module BatNum:Operation on arbitrary-precision numbers.sig
..end
Numbers (type BatNum.num
) are arbitrary-precision rational numbers,
plus the special elements 1/0
(infinity) and 0/0
(undefined).
Author(s): Valerie Menissier-Morain (base module), Gabriel Scherer, David Teller
typenum =
Num.num
=
| |
Int of |
| |
Big_int of |
| |
Ratio of |
typet =
num
val zero : num
val one : num
val neg : num -> num
val abs : num -> num
val add : num -> num -> num
val sub : num -> num -> num
val mul : num -> num -> num
val div : num -> num -> num
val modulo : num -> num -> num
val pow : num -> num -> num
val compare : num -> num -> int
val of_int : int -> num
val to_int : num -> int
val of_float : float -> num
val to_float : num -> float
val of_string : string -> num
val to_string : num -> string
val (+) : num -> num -> num
val (-) : num -> num -> num
val ( * ) : num -> num -> num
val (/) : num -> num -> num
val ( ** ) : num -> num -> num
val (<>) : num -> num -> bool
val (>=) : num -> num -> bool
val (<=) : num -> num -> bool
val (>) : num -> num -> bool
val (<) : num -> num -> bool
val (=) : num -> num -> bool
val max_num : num -> num -> num
val min_num : num -> num -> num
val quo : num -> num -> num
val square : num -> num
val succ : num -> num
val pred : num -> num
val is_integer : num -> bool
is_integer x
returns true
if x
represents an integer value,
false
otherwiseval round : num -> num
val floor : num -> num
val ceil : num -> num
val approx : num -> num
approx n
return the integer closest to n
val sign : num -> int
-1
, 0
or 1
according to the sign of the argument.val operations : num BatNumber.numeric
val (=/) : num -> num -> bool
val (</) : num -> num -> bool
val (>/) : num -> num -> bool
val (<=/) : num -> num -> bool
val (>=/) : num -> num -> bool
val (<>/) : num -> num -> bool
val eq_num : num -> num -> bool
val lt_num : num -> num -> bool
val le_num : num -> num -> bool
val gt_num : num -> num -> bool
val ge_num : num -> num -> bool
val approx_num_fix : int -> num -> string
Num.approx_num_exp
.val approx_num_exp : int -> num -> string
Num.approx_num_fix
uses decimal notation; the first
argument is the number of digits after the decimal point.
approx_num_exp
uses scientific (exponential) notation; the
first argument is the number of digits in the mantissa.val nat_of_num : num -> Nat.nat
val num_of_nat : Nat.nat -> num
val num_of_big_int : Big_int.big_int -> num
val big_int_of_num : num -> Big_int.big_int
val ratio_of_num : num -> Ratio.ratio
val num_of_ratio : Ratio.ratio -> num
val float_of_num : num -> float
val print : 'a BatInnerIO.output -> t -> unit