Module Prime_float
Floating point functions.
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
, or1.0
wherex
is negative, zero, or positive, respectively.
val round : float -> float
round x
is the whole number closest tox
, rounding towards zero in case of a tie.
val to_fraction : ?max_denom:int -> float -> int * int
to_fraction x
returns(n, d)
such thatn/d
is a best rational approximation ofx
. 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.