Module Float_u.O

A sub-module designed to be opened to make working with floats more convenient.

val unbox : float -> float
val box : float -> float
val (+) : t -> t -> t
val (-) : t -> t -> t
val (*) : t -> t -> t
val (/) : t -> t -> t
val (%) : t -> t -> t

In analogy to Int.( % ), ( % ):

  • always produces non-negative (or NaN) result
  • raises when given a negative modulus.

Like the other infix operators, NaNs in mean NaNs out.

Other cases: (a % Infinity) = a when 0 <= a < Infinity, (a % Infinity) = Infinity when -Infinity < a < 0, (+/- Infinity % a) = NaN, (a % 0) = NaN.

val (**) : t -> t -> t
val (~-) : t -> t
val (>=) : t -> t -> bool
val (<=) : t -> t -> bool
val (=) : t -> t -> bool
val (>) : t -> t -> bool
val (<) : t -> t -> bool
val (<>) : t -> t -> bool
val abs : t -> t
val neg : t -> t
val of_int : int -> t

Note that this doesn't round trip in either direction. For example, Float.to_int (Float.of_int max_int) <> max_int.