module BatNum: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 : numval 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 ord : num -> num -> BatOrd.orderval equal : num -> num -> boolval 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 max_num : num -> num -> numval min_num : num -> num -> numval quo : num -> num -> num
Euclidian divisiom
val square : num -> numval succ : num -> numInvalid_argument "Num.succ" for Num.Ratio _ argumentval pred : num -> numInvalid_argument "Num.pred" for Num.Ratio _ argumentval 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.natval 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 -> unitmodule TaggedInfix:sig..end
module Infix:sig..end
module Compare:BatNumber.Comparewith type bat__compare_t = t
val (+/) : num -> num -> numval add_num : num -> num -> numval minus_num : num -> numval (-/) : num -> num -> numval sub_num : num -> num -> numval ( */ ) : num -> num -> numval mult_num : num -> num -> numval square_num : num -> numval (//) : num -> num -> numval div_num : num -> num -> numval quo_num : num -> num -> numval mod_num : num -> num -> numval ( **/ ) : num -> num -> numval power_num : num -> num -> numval abs_num : num -> numval succ_num : num -> numval pred_num : num -> numval incr_num : num Pervasives.ref -> unitval decr_num : num Pervasives.ref -> unitval is_integer_num : num -> boolval integer_num : num -> numval floor_num : num -> numval round_num : num -> numval ceiling_num : num -> numval sign_num : num -> intval string_of_num : num -> stringval num_of_string : string -> numval int_of_num : num -> intval num_of_int : int -> numval compare_num : num -> num -> int