module type S = sig
.. end
type
t
type
outer = t
include Floatable.S
include Stringable.S
include Hashable.S_binable
include Comparable.S_binable
include Robustly_comparable.S
val nan : t
val infinity : t
val neg_infinity : t
val max_value : t
val min_value : t
val zero : t
val epsilon : t
val epsilon_float : t
val max_finite_value : t
val min_positive_value : t
val of_int : int -> t
val to_int : t -> int
val of_int64 : int64 -> t
val to_int64 : t -> int64
val iround_towards_zero_exn : t -> int
iround_towards_zero_exn raises Invalid_argument when either trying to handle nan or
trying to handle a float outside the range (-. 2. ** 52., 2. ** 52.)
(since floats have 52 significant bits) or outside the range
(float min_int, float max_int)
val iround_towards_zero : t -> int option
iround_towards_zero returns None if iround_towards_zero_exn raises an exception
val iround_down_exn : t -> int
val iround_down : t -> int option
val iround_up_exn : t -> int
val iround_up : t -> int option
iround_nearest_exn raises Invalid_argument in the same cases as
iround_towards_zero_exn
val iround_nearest_exn : t -> int
iround_nearest returns None if iround_nearest_exn raises an exception
val iround_nearest : t -> int option
iround_nearest t
rounds t to the nearest int. Returns None when t is too large to
round to an int.
val round_down : t -> t
val round_up : t -> t
val round_towards_zero : t -> t
val round_nearest : t -> t
val round : t -> t
val is_nan : t -> bool
val is_inf : t -> bool
includes positive and negative Float.infinity
val min_inan : t -> t -> t
min and max that return the other value if one of the values is a nan
. Returns
nan
if both arguments are nan
.
val max_inan : t -> t -> t
val (+) : t -> t -> t
val (-) : t -> t -> t
val ( * ) : t -> t -> t
val (/) : t -> t -> t
module Parts: sig
.. end
Returns the fractional part and the whole (i.e.
val modf : t -> Parts.t
val mod_float : t -> t -> t
mod_float x y
returns a result with the same sign as x
. It returns nan
if y
is
0
. It is basically
let mod_float x y = x -. float(truncate(x/.y)) *. y
not
let mod_float x y = x -. floor(x/.y) *. y
and therefore resembles mod
on integers more than %
.
val add : t -> t -> t
val sub : t -> t -> t
val neg : t -> t
val scale : t -> t -> t
val abs : t -> t
val to_string_hum : ?decimals:int -> ?strip_zero:bool -> float -> string
Pretty print float, for example to_string_hum ~decimals:3 1234.1999 = "1,234.200"
to_string_hum ~decimals:3 ~strip_zero:true 1234.1999 = "1,234.2"
. By default
decimals
is 3 and strip_zero
is false
val ldexp : t -> int -> t
val frexp : t -> t * int
module Class: sig
.. end
val classify : t -> Class.t
module Sign: sig
.. end
val sign : t -> Sign.t
module Terse: sig
.. end
val outer_of_sexp : Sexplib.Sexp.t -> outer
val sexp_of_outer : outer -> Sexplib.Sexp.t
val bin_outer : outer Bin_prot.Type_class.t
val bin_read_outer : outer Bin_prot.Read_ml.reader
val bin_read_outer_ : outer Bin_prot.Unsafe_read_c.reader
val bin_read_outer__ : (int -> outer) Bin_prot.Unsafe_read_c.reader
val bin_reader_outer : outer Bin_prot.Type_class.reader
val bin_size_outer : outer Bin_prot.Size.sizer
val bin_write_outer : outer Bin_prot.Write_ml.writer
val bin_write_outer_ : outer Bin_prot.Unsafe_write_c.writer
val bin_writer_outer : outer Bin_prot.Type_class.writer
iround_towards_zero_exn raises Invalid_argument when either trying to handle nan or
trying to handle a float outside the range (-. 2. ** 52., 2. ** 52.)
(since floats have 52 significant bits) or outside the range
(float min_int, float max_int)
iround_towards_zero returns None if iround_towards_zero_exn raises an exception
iround_nearest_exn raises Invalid_argument in the same cases as
iround_towards_zero_exn
iround_nearest returns None if iround_nearest_exn raises an exception
iround_nearest t
rounds t to the nearest int. Returns None when t is too large to
round to an int.
includes positive and negative Float.infinity
min and max that return the other value if one of the values is a nan
. Returns
nan
if both arguments are nan
.
Returns the fractional part and the whole (i.e. integer) part. For example, modf
(-3.14)
returns { fractional = -0.14; integral = -3.; }
!
mod_float x y
returns a result with the same sign as x
. It returns nan
if y
is
0
. It is basically
let mod_float x y = x -. float(truncate(x/.y)) *. y
not
let mod_float x y = x -. floor(x/.y) *. y
and therefore resembles mod
on integers more than %
.
Pretty print float, for example to_string_hum ~decimals:3 1234.1999 = "1,234.200"
to_string_hum ~decimals:3 ~strip_zero:true 1234.1999 = "1,234.2"
. By default
decimals
is 3 and strip_zero
is false