module Num:Operation on arbitrary-precision numbers.sig..end
Numbers (type num) are arbitrary-precision rational numbers,
plus the special elements 1/0 (infinity) and 0/0 (undefined).
type num =
| |
Int of |
| |
Big_int of |
| |
Ratio of |
val (+/) : num -> num -> numNum.add_num.val add_num : num -> num -> numval minus_num : num -> numval (-/) : num -> num -> numNum.sub_num.val sub_num : num -> num -> numval ( */ ) : num -> num -> numNum.mult_num.val mult_num : num -> num -> numval square_num : num -> numval (//) : num -> num -> numNum.div_num.val div_num : num -> num -> numval quo_num : num -> num -> numval mod_num : num -> num -> numval ( **/ ) : num -> num -> numNum.power_num.val power_num : num -> num -> numval abs_num : num -> numval succ_num : num -> numsucc n is n+1val pred_num : num -> numpred n is n-1val incr_num : num ref -> unitincr r is r:=!r+1, where r is a reference to a number.val decr_num : num ref -> unitdecr r is r:=!r-1, where r is a reference to a number.val is_integer_num : num -> boolval integer_num : num -> numinteger_num n returns the integer closest to n. In case of ties,
rounds towards zero.val floor_num : num -> numfloor_num n returns the largest integer smaller or equal to n.val round_num : num -> numround_num n returns the integer closest to n. In case of ties,
rounds off zero.val ceiling_num : num -> numceiling_num n returns the smallest integer bigger or equal to n.val sign_num : num -> int-1, 0 or 1 according to the sign of the argument.val (=/) : 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 compare_num : num -> num -> int-1, 0 or 1 if the first argument is less than,
equal to, or greater than the second argument.val max_num : num -> num -> numval min_num : num -> num -> numval string_of_num : num -> stringval 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 num_of_string : string -> numval int_of_num : num -> intval num_of_int : int -> numval 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 -> float