Module CCFloat
Basic operations on floating-point numbers
- since
- 0.6.1
type t= floattype fpclass= CCShims_.Stdlib.fpclass=|FP_normal|FP_subnormal|FP_zero|FP_infinite|FP_nan
val nan : tnanis Not a Number (NaN). Equal toStdlib.nan.
val max_value : tmax_valueis Positive infinity. Equal toStdlib.infinity.
val min_value : tmin_valueis Negative infinity. Equal toStdlib.neg_infinity.
val max_finite_value : tmax_finite_valueis the largest finite float value. Equal toStdlib.max_float.
val epsilon : tepsilonis the smallest positive float x such that1.0 +. x <> 1.0. Equal toStdlib.epsilon_float.
val pi : tpiis the constant pi. The ratio of a circumference to its diameter.- since
- 3.0
val is_nan : t -> boolis_nan freturnstrueif f is NaN,falseotherwise.
val abs : t -> tabs xis the absolute value of the floating-point numberx. Equal toStdlib.abs_float.
type 'a printer= Stdlib.Format.formatter -> 'a -> unittype 'a random_gen= Stdlib.Random.State.t -> 'a
val pp : t printerval hash : t -> intval random : t -> t random_genval random_small : t random_genval random_range : t -> t -> t random_genval fsign : t -> tfsign xis one of-1., -0., +0., +1., ornanifxis NaN.- since
- 0.7
val round : t -> tround xreturns the closest integer value, either above or below. Forn + 0.5,roundreturnsn.- since
- 0.20
val sign_exn : t -> intsign_exn xwill return the sign ofxas1, 0or-1, or raise an exceptionTrapNaNifxis NaN. Note that infinities have defined signs in OCaml.- since
- 0.7
val to_int : t -> intAlias to
int_of_float. Unspecified if outside of the range of integers.
val of_int : int -> tAlias to
float_of_int.
val to_string : t -> stringval of_string_exn : string -> tAlias to
float_of_string.- raises Failure
in case of failure.
- since
- 1.2
val of_string_opt : string -> t option- since
- 3.0
val equal_precision : epsilon:t -> t -> t -> boolEquality with allowed error up to a non negative epsilon value.
val classify : t -> fpclassclassify xreturns the class of the given floating-point numberx: normal, subnormal, zero, infinite or nan (not a number).
Infix Operators
- since
- 0.17
module Infix : sig ... end