Module Prime_float

Floating point functions.

val e : float

e is the Euler's number e.

val pi : float

pi is the ratio π of the circumference to the diameter of a circle in the Euclidean plane.

val sign : float -> float

sign x is -1.0, 0.0, or 1.0 where x is negative, zero, or positive, respectively.

val round : float -> float

round x is the whole number closest to x, rounding towards zero in case of a tie.

val to_fraction : ?⁠max_denom:int -> float -> int * int

to_fraction x returns (n, d) such that n/d is a best rational approximation of x. The result is based on the continued fraction of the absolute value, with sign copied to the numerator.

parameter max_denom

The maximum denominator to return. The default is currenty 230 to account for rounding errors and the width of int on 32 bit platforms, but it may be tuned in future versions.