package batteries
Install
Dune Dependency
Authors
Maintainers
Sources
md5=ea26b5c72e6731e59d856626049cca4d
sha512=55975b62c26f6db77433a3ac31f97af609fc6789bb62ac38b267249c78fd44ff37fe81901f1cf560857b9493a6046dd37b0d1c0234c66bd59e52843aac3ce6cb
doc/batteries.unthreaded/BatNum/index.html
Module BatNum
Source
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 -> string
See Num.approx_num_exp
.
val approx_num_exp : int -> num -> string
Approximate 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.nat
Coercions between numerical types
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
Boilerplate code
Printing
Submodules grouping all infix operators
Deprecated
val is_integer_num : num -> bool
val sign_num : num -> int
val string_of_num : num -> string
val num_of_string : string -> num
val int_of_num : num -> int
val num_of_int : int -> num