module type S =sig
..end
type
t
val typerep_of_t : t Typerep_kernel.Std.Typerep.t
val typename_of_t : t Typerep_kernel.Std.Typename.t
typeouter =
t
val typerep_of_outer : outer Typerep_kernel.Std.Typerep.t
val typename_of_outer : outer Typerep_kernel.Std.Typename.t
include Floatable.S
include Identifiable.S
max
and min
will return nan if either argument is nan.
The validate_*
functions always fail if class is Nan
or Infinite
.
include Comparable.With_zero
include Robustly_comparable.S
nan
should be considered undefined.val validate_ordinary : t Validate.check
validate_ordinary
fails if class is Nan
or Infinite
.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_subnormal_value : t
min_positive_subnormal_value = 2 ** -1074
min_positive_normal_value = 2 ** -1022
val min_positive_normal_value : t
val of_int : int -> t
val to_int : t -> int
val of_int64 : int64 -> t
val to_int64 : t -> int64
val round : ?dir:[ `Down | `Nearest | `Up | `Zero ] -> t -> t
val iround : ?dir:[ `Down | `Nearest | `Up | `Zero ] -> t -> int option
val iround_exn : ?dir:[ `Down | `Nearest | `Up | `Zero ] -> t -> int
val round_towards_zero : t -> t
val round_down : t -> t
val round_up : t -> t
val round_nearest : t -> t
val iround_towards_zero : t -> int option
val iround_down : t -> int option
val iround_up : t -> int option
val iround_nearest : t -> int option
val iround_towards_zero_exn : t -> int
val iround_down_exn : t -> int
val iround_up_exn : t -> int
val iround_nearest_exn : t -> int
val iround_lbound : t
f <= iround_lbound || f >= iround_ubound
, then iround*
functions will refuse
to round f
, returning None
or raising as appropriate.val iround_ubound : t
val is_nan : t -> bool
val is_inf : t -> bool
val min_inan : t -> t -> t
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
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
module O:sig
..end
val to_string_round_trippable : float -> string
to_string
, but guaranteed to be round-trippable.
It usually yields as few significant digits as possible. That is, it won't print
3.14
as 3.1400000000000001243
. The only exception is that occasionally it will
output 17 significant digits when the number can be represented with just 16 (but
not 15 or less) of them.
val to_string_hum : ?delimiter:char -> ?decimals:int -> ?strip_zero:bool -> float -> string
to_string_hum ~decimals:3 1234.1999 = "1_234.200"
to_string_hum ~decimals:3 ~strip_zero:true 1234.1999 = "1_234.2"
. No delimiters
are inserted to the right of the decimal.val ldexp : t -> int -> t
val frexp : t -> t * int
module Class:sig
..end
val classify : t -> Class.t
val is_finite : t -> bool
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.reader
val __bin_read_outer__ : (int -> outer) Bin_prot.Read.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.writer
val bin_writer_outer : outer Bin_prot.Type_class.writer
max
and min
will return nan if either argument is nan.
The validate_*
functions always fail if class is Nan
or Infinite
.
The results of robust comparisons on nan
should be considered undefined.
validate_ordinary
fails if class is Nan
or Infinite
.
min_positive_subnormal_value = 2 ** -1074
min_positive_normal_value = 2 ** -1022
If f <= iround_lbound || f >= iround_ubound
, then iround*
functions will refuse
to round f
, returning None
or raising as appropriate.
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 %
.
A sub-module designed to be opened to make working with floats more convenient.
Like to_string
, but guaranteed to be round-trippable.
It usually yields as few significant digits as possible. That is, it won't print
3.14
as 3.1400000000000001243
. The only exception is that occasionally it will
output 17 significant digits when the number can be represented with just 16 (but
not 15 or less) of them.
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"
. No delimiters
are inserted to the right of the decimal.