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 : numval neg : num -> numval abs : num -> numval add : num -> num -> numval sub : num -> num -> numval mul : num -> num -> numval div : num -> num -> numval modulo : num -> num -> numval pow : num -> num -> numval compare : num -> num -> intval of_int : int -> numval to_int : num -> intval of_float : float -> numval to_float : num -> floatval of_string : string -> numval to_string : num -> stringval (+) : num -> num -> numval (-) : num -> num -> numval ( * ) : num -> num -> numval (/) : num -> num -> numval ( ** ) : num -> num -> numval (<>) : num -> num -> boolval (>=) : num -> num -> boolval (<=) : num -> num -> boolval (>) : num -> num -> boolval (<) : num -> num -> boolval (=) : num -> num -> boolval max_num : num -> num -> numval min_num : num -> num -> numval quo : num -> num -> num
val square : num -> numval succ : num -> numval pred : num -> numval is_integer : num -> boolis_integer x returns true if x represents an integer value,
false otherwiseval round : num -> numval floor : num -> numval ceil : num -> numval approx : num -> numapprox n return the integer closest to nval sign : num -> int-1, 0 or 1 according to the sign of the argument.val operations : num BatNumber.numericval (=/) : num -> num -> boolval (</) : num -> num -> boolval (>/) : num -> num -> boolval (<=/) : num -> num -> boolval (>=/) : num -> num -> boolval (<>/) : num -> num -> boolval eq_num : num -> num -> boolval lt_num : num -> num -> boolval le_num : num -> num -> boolval gt_num : num -> num -> boolval ge_num : num -> num -> boolval approx_num_fix : int -> num -> stringNum.approx_num_exp.val approx_num_exp : int -> num -> stringNum.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 -> numval num_of_big_int : Big_int.big_int -> numval big_int_of_num : num -> Big_int.big_intval ratio_of_num : num -> Ratio.ratioval num_of_ratio : Ratio.ratio -> numval float_of_num : num -> floatval print : 'a BatInnerIO.output -> t -> unit