module Float: BatFloattypet =float
The type of floating-point numbers.
Floating-point numbers are the default representation of real numbers by OCaml.
val zero : floatFloating number zero. This is the same thing as 0.
val one : floatFloating number one. This is the same thing as 1.
val neg : float -> floatReturns the negation of the input, i.e. (fun x -> ~-. x)
val succ : float -> floatAdd 1. 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 -> floatSubtract 1. 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 -> floatThe absolute value of a floating point number.
val add : float -> float -> float
val sub : float -> float -> float
val mul : float -> float -> float
val div : float -> float -> float
val modulo : float -> float -> float
val pow : float -> float -> float
val min_num : bounded
val max_num : bounded
val compare : float -> float -> int
val equal : float -> float -> bool
val ord : float -> float -> BatOrd.order
val of_int : int -> float
val to_int : float -> int
val of_float : float -> float
val to_float : float -> float
val of_string : string -> float
val to_string : float -> string
val (+) : t -> t -> t
val (-) : t -> t -> t
val ( * ) : t -> t -> t
val (/) : t -> t -> t
val ( ** ) : t -> t -> t
val min : float -> float -> float
val max : float -> float -> float
val (--) : t -> t -> t BatEnum.t
val (---) : t -> t -> t BatEnum.t
val operations : t BatNumber.numericval sqrt : float -> floatSquare root.
val exp : float -> floatExponential.
val log : float -> floatNatural logarithm.
val log10 : float -> floatBase 10 logarithm.
val cos : float -> floatSee BatFloat.atan2.
val sin : float -> floatSee BatFloat.atan2.
val tan : float -> floatSee BatFloat.atan2.
val acos : float -> floatSee BatFloat.atan2.
val asin : float -> floatSee BatFloat.atan2.
val atan : float -> floatSee BatFloat.atan2.
val atan2 : float -> float -> floatThe usual trigonometric functions.
val cosh : float -> floatSee BatFloat.tanh.
val sinh : float -> floatSee BatFloat.tanh.
val tanh : float -> floatThe usual hyperbolic trigonometric functions.
val ceil : float -> floatSee BatFloat.floor.
val floor : float -> floatRound the given float to an integer value.
floor 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 round : float -> floatround x rounds x to the nearest integral floating-point
(the nearest of floor x and ceil x). In case the fraction
of x is exactly 0.5, we round away from 0. : round 1.5 is
2. but round (-3.5) is -4..
val round_to_int : float -> intround_to_int x is int_of_float (round x).
val round_to_string : ?digits:int -> float -> stringround_to_string ~digits:d x will return a string
representation of x -- in base 10 -- rounded to d digits
after the decimal point. By default, digits is 0, we round
to the nearest integer.
Invalid_argument if the ~digits argument is negative.
This is strictly a convenience function for simple end-user
printing and you should not rely on its behavior. One possible
implementation is to rely on C `sprintf` internally, which
means:
round or round_to_intround_to_string ~digits:0 3. may return "3" instead of
"3." as string_of_float wouldround_to_string
~digits:max_int x may return the empty string.val root : float -> int -> floatroot x n calculates the nth root of x.
Invalid_argument if n is negative or if the result would
be imaginaryval signbit : float -> boolx is set. This usually indicates thet x is negative.val copysign : float -> float -> floatcopysign x y returns a copy of x with the same sign as y.
val is_nan : float -> boolis_nan f returns true if f is nan, false otherwise.
val is_special : float -> boolis_special f returns true if f is nan or +/- infinity,
false otherwise.
val is_finite : float -> boolis_finite f returns true if f is not nan or +/- infinity,
false otherwise.
Special float constants. It may not be safe to compare
directly with these, as they have multiple internal
representations. Instead use the is_special, is_nan,
etc. tests
val infinity : floatPositive infinity.
val neg_infinity : floatNegative infinity.
val nan : floatA special floating-point value denoting the result of an
undefined operation such as 0.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.
Numeric constants
val epsilon : floatThe smallest positive float x such that 1.0 +. x <> 1.0.
val e : floatEuler? ... Euler? ... Euler?
val log2e : floatMath.log2 e
val log10e : floatlog10 e
val ln2 : floatlog 2
val ln10 : floatlog 10
val pi : floatThe constant pi (3.14159...)
val pi2 : floatpi /. 2.
val pi4 : floatpi /. 4.
val invpi : float1. /. pi
val invpi2 : float2. /. pi
val sqrtpi2 : float2. *. sqrt pi
val sqrt2 : floatsqrt 2.
val invsqrt2 : float1. /. sqrt 2.
val 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 =Stdlib.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 | *) |
Classes of floating point numbers
The five classes of floating-point numbers, as determined by
the BatFloat.classify function.
val classify : float -> fpkindReturn the class of the given floating-point number: normal, subnormal, zero, infinite, or not a number.
val approx_equal : ?epsilon:float -> float -> float -> boolTest whether two floats are approximately equal (i.e. within
epsilon of each other). epsilon defaults to 1e-5.
module Infix:sig..end
module Compare:BatNumber.Comparewith type bat__compare_t = t
include BatNumber.RefOps
include BatNumber.Bounded
val print : (t, 'a) BatIO.printermodule Safe_float:sig..end
Operations on floating-point numbers, with exceptions raised in case of error.