module Safe_float:Operations on floating-point numbers, with exceptions raised in case of error.sig..end
The operations implemented in this module are the same as the operations
implemented in module Float, with the exception that no operation returns
nan, infinity or neg_infinity. In case of overflow, instead of returning
infinity or neg_infinity, operations raise exception Number.Overflow.
In case of nan, operations raise exception Number.NaN.
Caml's floating-point numbers follow the IEEE 754 standard, using
double precision (64 bits) numbers. Floating-point operations never
raise an exception on overflow, underflow, division by zero,
etc. Instead, special IEEE numbers are returned as appropriate,
such as infinity for 1.0 /. 0.0, neg_infinity for -1.0 /. 0.0, and
nan (``not a number'') for 0.0 /. 0.0. These special numbers then
propagate through floating-point computations as expected: for
instance, 1.0 /. infinity is 0.0, and any operation with nan as
argument returns nan as result.
For more precision, see
The Wikipedia entry on
standard IEEE 754.
Author(s): David Teller
typet =float
Floating-point numbers are the default representation of
real numbers by OCaml.
val zero : float0.val one : float1.val neg : float -> floatval succ : float -> float1. to a floating number. Note that, as per IEEE 754,
if x is a large enough float number, succ x might be
equal to x, due to rounding.val pred : float -> float1. from a floating number. Note that, as per
IEEE 754, if x is a large enough float number, pred x
might be equal to x, due to rounding.val abs : float -> floatval add : float -> float -> floatval sub : float -> float -> floatval mul : float -> float -> floatval div : float -> float -> floatval modulo : float -> float -> floatval pow : float -> float -> floatval min_num : floatval max_num : floatval compare : 'a -> 'a -> intval of_int : int -> floatval to_int : float -> intval of_float : float -> floatval to_float : float -> floatval of_string : string -> floatval to_string : float -> stringval (+) : t -> t -> tval (-) : t -> t -> tval ( * ) : t -> t -> tval (/) : t -> t -> tval ( ** ) : t -> t -> tval (<>) : t -> t -> boolval (>=) : t -> t -> boolval (<=) : t -> t -> boolval (>) : t -> t -> boolval (<) : t -> t -> boolval (=) : t -> t -> boolval operations : t BatNumber.numericval exp : float -> floatval log : float -> floatval log10 : float -> floatval cos : float -> float
val sin : float -> float
val tan : float -> float
val acos : float -> float
val asin : float -> float
val atan : float -> float
val atan2 : float -> float -> floatval cosh : float -> float
val sinh : float -> float
val tanh : float -> floatval ceil : float -> float
val floor : float -> floatfloor f returns the greatest integer value less than or
equal to f.
ceil f returns the least integer value greater than or
equal to f.val infinity : floatval neg_infinity : floatval nan : float0.0 /. 0.0. Stands for
``not a number''. Any floating-point operation with nan as
argument returns nan as result. As for floating-point comparisons,
=, <, <=, > and >= return false and <> returns true
if one or both of their arguments is nan.val is_nan : float -> boolis_nan f returns true if f is nan, false otherwise.val epsilon : floatx such that 1.0 +. x <> 1.0.val pi : floatval frexp : float -> float * intfrexp f returns the pair of the significant
and the exponent of f. When f is zero, the
significant x and the exponent n of f are equal to
zero. When f is non-zero, they are defined by
f = x *. 2 ** n and 0.5 <= x < 1.0.val ldexp : float -> int -> floatldexp x n returns x *. 2 ** n.val modf : float -> float * floatmodf f returns the pair of the fractional and integral
part of f.typefpkind =Pervasives.fpclass=
| |
FP_normal |
(* | Normal number, none of the below | *) |
| |
FP_subnormal |
(* | Number very close to 0.0, has reduced precision | *) |
| |
FP_zero |
(* | Number is 0.0 or -0.0 | *) |
| |
FP_infinite |
(* | Number is positive or negative infinity | *) |
| |
FP_nan |
(* | Not a number: result of an undefined operation | *) |
The five classes of floating-point numbers, as determined by
the BatFloat.Safe_float.classify function.
val classify : float -> fpkindval print : 'a BatInnerIO.output -> t -> unit
val t_printer : t BatValue_printer.t