package mopsa
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=37966e98ffeebcedc09bd6e9b2b81f69
sha512=40d4d826c25f680766c07eccbabdf5e8a4fa023016e8a164e4e4f6b3781c8484dc4df437055721dfd19b9db8fb7fe3b61236c4833186d346fc7204a68d01eaaa
doc/mopsa.mopsa_utils/Mopsa_utils/ItvUtils/Float/index.html
Module ItvUtils.Float
Float - Floating-point arihmetics with rounding.
We rely on C code to provide functions with correct rounding (rounding direction and rounding precision).
Types
type bit_float = {
sign : bool;
(*sign bit (true means negative)
*)fraction : Z.t;
(*fraction bits
*)exponent : int;
(*exponent (positive, with bias)
*)
}
Bit-representation of a float value.
Global rounding direction
Set the rounding mode globally. This affects the behaviors of all floating-point operations, including OCaml's native float operations, but excluding the operations in this module (and the float interval module) that specify a rounding direction.
Note that the operations with specified rounding directions may change the rounding direction globally in some unspecified way, and not reset it to its former value (this is done for efficiency).
Operations without rounding
val infinite : int -> t
Constructs an infinity with the given sign. Zero maps to zero.
Predicates
val is_nan : t -> bool
val is_finite : t -> bool
Whether x is finite or not (infinite or NaN).
val is_infinite : t -> bool
val is_normal : t -> bool
val is_denormal : t -> bool
val sign : t -> int
Sign of x: -1 (negative), 0 (zero or NaN), or 1 (positive).
val sign_zero : t -> int
As sign, but zero is signed. Returns -1 (negative or -0), 0 (NaN), or 1 (positive of +0)
val is_zero : t -> bool
val is_nonzero : t -> bool
val is_positive : t -> bool
val is_negative : t -> bool
val is_positive_strict : t -> bool
val is_negative_strict : t -> bool
Sign predicates.
Printing
val dfl_fmt : print_format
Default format.
val hex_fmt : print_format
val to_string : print_format -> t -> string
val print : print_format -> out_channel -> t -> unit
val fprint : print_format -> Format.formatter -> t -> unit
val bprint : print_format -> Buffer.t -> t -> unit
Operations with specific rounding direction and precision
We provide the classic operations (and more) for single and double precision and all four rounding directions.
module Single : sig ... end
Single precision operations.
module Double : sig ... end
Double precision operations.
Operations with rounding mode as argument
Rounding direction.
val mantissa_bits : prec -> int
val exponent_bits : prec -> int
val exponent_bias : prec -> int
val min_exponent : prec -> int
val max_exponent : prec -> int
val nan_infinity_exponent : prec -> int
Useful constants.
Bit-level extraction.