33(* * Basic operations on floating-point numbers
44 @since 0.6.1 *)
55
6-
7-
8- type t = float
9-
10- type fpclass = Stdlib .fpclass =
11- | FP_normal
12- | FP_subnormal
13- | FP_zero
14- | FP_infinite
15- | FP_nan
16-
17- val nan : t
18- (* * [nan] is Not a Number (NaN). Equal to {!Stdlib.nan}. *)
6+ include module type of Float
197
208val max_value : t
219(* * [max_value] is Positive infinity. Equal to {!Stdlib.infinity}. *)
@@ -26,50 +14,13 @@ val min_value : t
2614val max_finite_value : t
2715(* * [max_finite_value] is the largest finite float value. Equal to {!Stdlib.max_float}. *)
2816
29- val epsilon : t
30- (* * [epsilon] is the smallest positive float x such that [1.0 +. x <> 1.0].
31- Equal to {!Stdlib.epsilon_float}. *)
32-
33- val pi : t
34- (* * [pi] is the constant pi. The ratio of a circumference to its diameter.
35- @since 3.0 *)
36-
37- val is_nan : t -> bool
38- (* * [is_nan f] returns [true] if f is NaN, [false] otherwise. *)
39-
40- val add : t -> t -> t
41- (* * [add x y] is equal to [x +. y]. *)
42-
43- val sub : t -> t -> t
44- (* * [sub x y] is equal to [x -. y]. *)
45-
46- val neg : t -> t
47- (* * [neg x] is equal to [~-. x]. *)
48-
49- val abs : t -> t
50- (* * [abs x] is the absolute value of the floating-point number [x].
51- Equal to {!Stdlib.abs_float}. *)
52-
5317val scale : t -> t -> t
5418(* * [scale x y] is equal to [x *. y]. *)
5519
56- val min : t -> t -> t
57- (* * [min x y] returns the min of the two given values [x] and [y]. *)
58-
59- val max : t -> t -> t
60- (* * [max x y] returns the max of the two given values [x] and [y]. *)
61-
62- val equal : t -> t -> bool
63- (* * [equal x y] is [true] if [x] and [y] are the same. *)
64-
65- val compare : t -> t -> int
66- (* * [compare x y] is {!Stdlib.compare x y}. *)
67-
6820type 'a printer = Format .formatter -> 'a -> unit
6921type 'a random_gen = Random.State .t -> 'a
7022
7123val pp : t printer
72- val hash : t -> int
7324val random : t -> t random_gen
7425val random_small : t random_gen
7526val random_range : t -> t -> t random_gen
@@ -78,11 +29,6 @@ val fsign : t -> t
7829(* * [fsign x] is one of [-1., -0., +0., +1.], or [nan] if [x] is NaN.
7930 @since 0.7 *)
8031
81- val round : t -> t
82- (* * [round x] returns the closest integer value, either above or below.
83- For [n + 0.5], [round] returns [n].
84- @since 0.20 *)
85-
8632exception TrapNaN of string
8733
8834val sign_exn : t -> int
@@ -91,23 +37,11 @@ val sign_exn : t -> int
9137 Note that infinities have defined signs in OCaml.
9238 @since 0.7 *)
9339
94- val to_int : t -> int
95- (* * Alias to {!int_of_float}.
96- Unspecified if outside of the range of integers. *)
97-
98- val of_int : int -> t
99- (* * Alias to {!float_of_int}. *)
100-
101- val to_string : t -> string
102-
10340val of_string_exn : string -> t
10441(* * Alias to {!float_of_string}.
10542 @raise Failure in case of failure.
10643 @since 1.2 *)
10744
108- val of_string_opt : string -> t option
109- (* * @since 3.0 *)
110-
11145val equal_precision : epsilon :t -> t -> t -> bool
11246(* * Equality with allowed error up to a non negative epsilon value. *)
11347
0 commit comments