Module Mpfr

module Mpfr: sig .. end
MPFR multi-precision floating-point numbers

type 'a tt 
type round = 
| Near
| Zero
| Up
| Down
| Away
| Faith
| NearAway

MPFR multi-precision floating-point numbers
type m 
Mutable tag
type f 
Functional (immutable) tag
type t = m tt 
Mutable multi-precision floating-point numbers

The following operations are mapped as much as possible to their C counterpart. In case of imperative functions (like set, add, ...) the first parameter of type t is an out-parameter and holds the result when the function returns. For instance, add x y z adds the values of y and z and stores the result in x.

These functions are as efficient as their C counterpart: they do not imply additional memory allocation.

Pretty printing


val print : Format.formatter -> 'a tt -> unit
val print_round : Format.formatter -> round -> unit
val string_of_round : round -> string

Rounding Modes



C documentation
val set_default_rounding_mode : round -> unit
val get_default_rounding_mode : unit -> round
val round_prec : t -> round -> int -> int

Exceptions



C documentation
val get_emin : unit -> int
val get_emax : unit -> int
val set_emin : int -> unit
val set_emax : int -> unit
val check_range : t -> int -> round -> int
val clear_underflow : unit -> unit
val clear_overflow : unit -> unit
val clear_nanflag : unit -> unit
val clear_inexflag : unit -> unit
val clear_flags : unit -> unit
val underflow_p : unit -> bool
val overflow_p : unit -> bool
val nanflag_p : unit -> bool
val inexflag_p : unit -> bool

Initialization Functions



C documentation
val set_default_prec : int -> unit
val get_default_prec : unit -> int
val init : unit -> 'a tt
val init2 : int -> 'a tt
val get_prec : 'a tt -> int
val set_prec : t -> int -> unit
val set_prec_raw : t -> int -> unit

Assignment Functions



C documentation
val set : t -> 'a tt -> round -> int
val set_si : t -> int -> round -> int
val set_d : t -> float -> round -> int
val set_z : t -> 'a Mpz.tt -> round -> int
val set_q : t -> 'a Mpq.tt -> round -> int
val _set_str : t -> string -> int -> round -> unit
val set_str : t -> string -> base:int -> round -> unit
val _strtofr : t -> string -> int -> round -> int * int
val strtofr : t -> string -> base:int -> round -> int * int

As MPFR's strtofr, but returns a pair (r,i) where r is the usual ternary result, and i is the index in the string of the first not-read character. Thus, i=0 when no number could be read at all, and is equal to the length of the string if everything was read.
val set_f : t -> 'a Mpf.tt -> round -> int
val set_si_2exp : t -> int -> int -> round -> int
val set_inf : t -> int -> unit
val set_nan : t -> unit
val swap : t -> t -> unit

Combined Initialization and Assignment Functions



C documentation
val init_set : 'a tt -> round -> int * 'b tt
val init_set_si : int -> round -> int * 'a tt
val init_set_d : float -> round -> int * 'a tt
val init_set_f : 'a Mpf.tt -> round -> int * 'b tt
val init_set_z : 'a Mpz.tt -> round -> int * 'b tt
val init_set_q : 'a Mpq.tt -> round -> int * 'b tt
val _init_set_str : string -> int -> round -> 'a tt
val init_set_str : string -> base:int -> round -> 'a tt

Conversion Functions



C documentation
val get_d : 'a tt -> round -> float
val get_d1 : 'a tt -> float
val get_z_exp : Mpz.t -> 'a tt -> int
val get_z : Mpz.t -> 'a tt -> round -> unit
val _get_str : int -> int -> 'a tt -> round -> string * int
val get_str : base:int -> digits:int -> t -> round -> string * int

User Conversions



These functionss are additions to or renaming of functions offered by the C library.
val to_string : 'a tt -> string
val to_float : ?round:round -> 'a tt -> float
val to_mpq : 'a tt -> 'b Mpq.tt
val of_string : string -> round -> 'a tt
val of_float : float -> round -> 'a tt
val of_int : int -> round -> 'a tt
val of_frac : int -> int -> round -> 'a tt
val of_mpz : 'a Mpz.tt -> round -> 'b tt
val of_mpz2 : 'a Mpz.tt -> 'b Mpz.tt -> round -> 'c tt
val of_mpq : 'a Mpq.tt -> round -> 'b tt

Basic Arithmetic Functions



C documentation
val add : t -> 'a tt -> 'b tt -> round -> int
val add_ui : t -> 'a tt -> int -> round -> int
val add_z : t -> 'a tt -> 'a Mpz.tt -> round -> int
val add_q : t -> 'a tt -> 'a Mpq.tt -> round -> int
val sub : t -> 'a tt -> 'b tt -> round -> int
val ui_sub : t -> int -> 'a tt -> round -> int
val sub_ui : t -> 'a tt -> int -> round -> int
val sub_z : t -> 'a tt -> 'a Mpz.tt -> round -> int
val sub_q : t -> 'a tt -> 'a Mpq.tt -> round -> int
val mul : t -> 'a tt -> 'b tt -> round -> int
val mul_ui : t -> 'a tt -> int -> round -> int
val mul_z : t -> 'a tt -> 'a Mpz.tt -> round -> int
val mul_q : t -> 'a tt -> 'a Mpq.tt -> round -> int
val mul_2ui : t -> 'a tt -> int -> round -> int
val mul_2si : t -> 'a tt -> int -> round -> int
val mul_2exp : t -> 'a tt -> int -> round -> int
val div : t -> 'a tt -> 'b tt -> round -> int
val ui_div : t -> int -> 'a tt -> round -> int
val div_ui : t -> 'a tt -> int -> round -> int
val div_z : t -> 'a tt -> 'a Mpz.tt -> round -> int
val div_q : t -> 'a tt -> 'a Mpq.tt -> round -> int
val div_2ui : t -> 'a tt -> int -> round -> int
val div_2si : t -> 'a tt -> int -> round -> int
val div_2exp : t -> t -> int -> round -> int
val sqrt : t -> 'a tt -> round -> bool
val sqrt_ui : t -> int -> round -> bool
val pow_ui : t -> 'a tt -> int -> round -> bool
val pow_si : t -> 'a tt -> int -> round -> bool
val ui_pow_ui : t -> int -> int -> round -> bool
val ui_pow : t -> int -> 'a tt -> round -> bool
val pow : t -> 'a tt -> 'b tt -> round -> bool
val neg : t -> 'a tt -> round -> int
val abs : t -> 'a tt -> round -> int

Comparison Functions



C documentation
val cmp : 'a tt -> 'b tt -> int
val cmp_si : 'a tt -> int -> int
val cmp_si_2exp : 'a tt -> int -> int -> int
val sgn : 'a tt -> int
val _equal : 'a tt -> 'b tt -> int -> bool
val equal : 'a tt -> 'b tt -> bits:int -> bool
val nan_p : 'a tt -> bool
val inf_p : 'a tt -> bool
val number_p : 'a tt -> bool
val reldiff : t -> 'a tt -> 'b tt -> round -> unit

Special Functions



C documentation
val log : t -> 'a tt -> round -> int
val log2 : t -> 'a tt -> round -> int
val log10 : t -> 'a tt -> round -> int
val exp : t -> 'a tt -> round -> int
val exp2 : t -> 'a tt -> round -> int
val exp10 : t -> 'a tt -> round -> int
val cos : 'a tt -> 'b tt -> round -> int
val sin : 'a tt -> 'b tt -> round -> int
val tan : 'a tt -> 'b tt -> round -> int
val sec : 'a tt -> 'b tt -> round -> int
val csc : 'a tt -> 'b tt -> round -> int
val cot : 'a tt -> 'b tt -> round -> int
val sin_cos : 'a tt -> 'b tt -> 'c tt -> round -> bool
val acos : t -> 'a tt -> round -> int
val asin : t -> 'a tt -> round -> int
val atan : t -> 'a tt -> round -> int
val atan2 : t -> 'a tt -> 'b tt -> round -> int
val cosh : 'a tt -> 'b tt -> round -> int
val sinh : 'a tt -> 'b tt -> round -> int
val tanh : 'a tt -> 'b tt -> round -> int
val sech : 'a tt -> 'b tt -> round -> int
val csch : 'a tt -> 'b tt -> round -> int
val coth : 'a tt -> 'b tt -> round -> int
val acosh : t -> 'a tt -> round -> int
val asinh : t -> 'a tt -> round -> int
val atanh : t -> 'a tt -> round -> int
val fac_ui : t -> int -> round -> int
val log1p : t -> 'a tt -> round -> int
val expm1 : t -> 'a tt -> round -> int
val eint : t -> 'a tt -> round -> int
val gamma : t -> 'a tt -> round -> int
val lngamma : t -> 'a tt -> round -> int
val zeta : t -> 'a tt -> round -> int
val erf : t -> 'a tt -> round -> int
val erfc : t -> 'a tt -> round -> int
val j0 : t -> 'a tt -> round -> int
val j1 : t -> 'a tt -> round -> int
val jn : t -> int -> 'a tt -> round -> int
val y0 : t -> 'a tt -> round -> int
val y1 : t -> 'a tt -> round -> int
val yn : t -> int -> 'a tt -> round -> int
val fma : t -> 'a tt -> 'b tt -> 'c tt -> round -> int
val fms : t -> 'a tt -> 'b tt -> 'c tt -> round -> int
val agm : t -> 'a tt -> 'b tt -> round -> int
val hypot : t -> 'a tt -> 'b tt -> round -> int
val const_log2 : t -> round -> int
val const_pi : t -> round -> int
val const_euler : t -> round -> int
val const_catalan : t -> round -> int

Input and Output Functions: not interfaced



Miscellaneous Float Functions



C documentation
val rint : t -> 'a tt -> round -> int
val ceil : t -> 'a tt -> int
val floor : t -> 'a tt -> int
val round : t -> 'a tt -> int
val trunc : t -> 'a tt -> int
val frac : t -> 'a tt -> round -> int
val modf : t -> t -> 'a tt -> round -> int
val fmod : t -> 'a tt -> 'b tt -> round -> int
val remainder : t -> 'a tt -> 'b tt -> round -> int
val integer_p : 'a tt -> bool
val nexttoward : t -> 'a tt -> unit
val nextabove : t -> unit
val nextbelow : t -> unit
val min : t -> 'a tt -> 'b tt -> round -> int
val max : t -> 'a tt -> 'b tt -> round -> int
val get_exp : 'a tt -> int
val set_exp : t -> int -> int