package batteries
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=b7f3b99f12f21b1da6b6aa13d993206d
sha512=8b7f2479eb0271bcfd9168887c1e4a9a815c512eab3ee61b150fc4dfa9ec803e4f73115155f20b3017e4a822148d0e6d1c1e8e5f96790fd691b419dd39a908a2
doc/batteries.unthreaded/BatNum/index.html
Module BatNumSource
Operation on arbitrary-precision numbers.
Numbers (type num) are arbitrary-precision rational numbers, plus the special elements 1/0 (infinity) and 0/0 (undefined).
@documents Num
The type of numbers.
Convert a number to a string, using fractional notation. Two formats are recognized: simple integer literals and a pair of integer literals separated by a '/', to indicate a rational number.
Convert a simple floating point literal to a num. Plain integer literals are also accepted; numbers written with a trailing exponent are not currently accepted.
is_integer x returns true if x represents an integer value, false otherwise
Comparisons between numbers
Coercions with strings
val approx_num_fix : int -> num -> stringSee Num.approx_num_exp.
val approx_num_exp : int -> num -> stringApproximate a number by a decimal. The first argument is the required precision. The second argument is the number to approximate. 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.natCoercions between numerical types
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 -> floatBoilerplate code
Printing
Submodules grouping all infix operators
Deprecated
val is_integer_num : num -> boolval sign_num : num -> intval string_of_num : num -> stringval num_of_string : string -> numval int_of_num : num -> intval num_of_int : int -> num