Module Float_u.OSource

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

Sourceval unbox : float -> float#
Sourceval box : float# -> float
Sourceval (+) : t -> t -> t [@@zero_alloc strict]
Sourceval (-) : t -> t -> t [@@zero_alloc strict]
Sourceval (*) : t -> t -> t [@@zero_alloc strict]
Sourceval (/) : t -> t -> t [@@zero_alloc strict]
Sourceval (%) : 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.

Sourceval (**) : t -> t -> t [@@zero_alloc strict]
Sourceval (~-) : t -> t [@@zero_alloc strict]
Sourceval (>=) : t -> t -> bool [@@zero_alloc strict]
Sourceval (<=) : t -> t -> bool [@@zero_alloc strict]
Sourceval (=) : t -> t -> bool [@@zero_alloc strict]
Sourceval (>) : t -> t -> bool [@@zero_alloc strict]
Sourceval (<) : t -> t -> bool [@@zero_alloc strict]
Sourceval (<>) : t -> t -> bool [@@zero_alloc strict]
Sourceval abs : t -> t [@@zero_alloc strict]
Sourceval neg : t -> t [@@zero_alloc strict]
Sourceval of_int : int -> t [@@zero_alloc strict]

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