33(* * Basic operations on floating-point numbers
44 @since 0.6.1 *)
55
6- type t = float
7-
8- type fpclass = Stdlib .fpclass =
9- | FP_normal
10- | FP_subnormal
11- | FP_zero
12- | FP_infinite
13- | FP_nan
14-
15- val nan : t
16- (* * [nan] is Not a Number (NaN). Equal to {!Stdlib.nan}. *)
6+ include module type of Float
7+ (* * @inline *)
178
189val max_value : t
1910(* * [max_value] is Positive infinity. Equal to {!Stdlib.infinity}. *)
@@ -24,50 +15,13 @@ val min_value : t
2415val max_finite_value : t
2516(* * [max_finite_value] is the largest finite float value. Equal to {!Stdlib.max_float}. *)
2617
27- val epsilon : t
28- (* * [epsilon] is the smallest positive float x such that [1.0 +. x <> 1.0].
29- Equal to {!Stdlib.epsilon_float}. *)
30-
31- val pi : t
32- (* * [pi] is the constant pi. The ratio of a circumference to its diameter.
33- @since 3.0 *)
34-
35- val is_nan : t -> bool
36- (* * [is_nan f] returns [true] if f is NaN, [false] otherwise. *)
37-
38- val add : t -> t -> t
39- (* * [add x y] is equal to [x +. y]. *)
40-
41- val sub : t -> t -> t
42- (* * [sub x y] is equal to [x -. y]. *)
43-
44- val neg : t -> t
45- (* * [neg x] is equal to [~-. x]. *)
46-
47- val abs : t -> t
48- (* * [abs x] is the absolute value of the floating-point number [x].
49- Equal to {!Stdlib.abs_float}. *)
50-
5118val scale : t -> t -> t
5219(* * [scale x y] is equal to [x *. y]. *)
5320
54- val min : t -> t -> t
55- (* * [min x y] returns the min of the two given values [x] and [y]. *)
56-
57- val max : t -> t -> t
58- (* * [max x y] returns the max of the two given values [x] and [y]. *)
59-
60- val equal : t -> t -> bool
61- (* * [equal x y] is [true] if [x] and [y] are the same. *)
62-
63- val compare : t -> t -> int
64- (* * [compare x y] is {!Stdlib.compare x y}. *)
65-
6621type 'a printer = Format .formatter -> 'a -> unit
6722type 'a random_gen = Random.State .t -> 'a
6823
6924val pp : t printer
70- val hash : t -> int
7125val random : t -> t random_gen
7226val random_small : t random_gen
7327val random_range : t -> t -> t random_gen
@@ -76,11 +30,6 @@ val fsign : t -> t
7630(* * [fsign x] is one of [-1., -0., +0., +1.], or [nan] if [x] is NaN.
7731 @since 0.7 *)
7832
79- val round : t -> t
80- (* * [round x] returns the closest integer value, either above or below.
81- For [n + 0.5], [round] returns [n].
82- @since 0.20 *)
83-
8433exception TrapNaN of string
8534
8635val sign_exn : t -> int
@@ -89,23 +38,11 @@ val sign_exn : t -> int
8938 Note that infinities have defined signs in OCaml.
9039 @since 0.7 *)
9140
92- val to_int : t -> int
93- (* * Alias to {!int_of_float}.
94- Unspecified if outside of the range of integers. *)
95-
96- val of_int : int -> t
97- (* * Alias to {!float_of_int}. *)
98-
99- val to_string : t -> string
100-
10141val of_string_exn : string -> t
10242(* * Alias to {!float_of_string}.
10343 @raise Failure in case of failure.
10444 @since 1.2 *)
10545
106- val of_string_opt : string -> t option
107- (* * @since 3.0 *)
108-
10946val equal_precision : epsilon :t -> t -> t -> bool
11047(* * Equality with allowed error up to a non negative epsilon value. *)
11148
0 commit comments