CCFloat
Basic operations on floating-point numbers
val nan : t
nan
is Not a Number (NaN). Equal to Stdlib.nan
.
val max_value : t
max_value
is Positive infinity. Equal to Stdlib.infinity
.
val min_value : t
min_value
is Negative infinity. Equal to Stdlib.neg_infinity
.
val max_finite_value : t
max_finite_value
is the largest finite float value. Equal to Stdlib.max_float
.
val epsilon : t
epsilon
is the smallest positive float x such that 1.0 +. x <> 1.0
. Equal to Stdlib.epsilon_float
.
val pi : t
pi
is the constant pi. The ratio of a circumference to its diameter.
val is_nan : t -> bool
is_nan f
returns true
if f is NaN, false
otherwise.
abs x
is the absolute value of the floating-point number x
. Equal to Stdlib.abs_float
.
val hash : t -> int
val random : t -> t random_gen
val random_small : t random_gen
val random_range : t -> t -> t random_gen
round x
returns the closest integer value, either above or below. For n + 0.5
, round
returns n
.
val sign_exn : t -> int
sign_exn x
will return the sign of x
as 1, 0
or -1
, or raise an exception TrapNaN
if x
is NaN. Note that infinities have defined signs in OCaml.
val to_int : t -> int
Alias to int_of_float
. Unspecified if outside of the range of integers.
val of_int : int -> t
Alias to float_of_int
.
val to_string : t -> string
val of_string_exn : string -> t
Alias to float_of_string
.
val of_string_opt : string -> t option
Equality with allowed error up to a non negative epsilon value.
classify x
returns the class of the given floating-point number x
: normal, subnormal, zero, infinite or nan (not a number).
module Infix : sig ... end
include module type of Infix