Module Mpfr

module Mpfr: sig .. end
MPFR multiprecision floating-point numbers

type t 
type round = 
| Near
| Zero
| Up
| Down

MPFR multiprecision 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 -> t -> 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 -> t
val init2 : int -> t
val get_prec : t -> int
val set_prec : t -> int -> unit
val set_prec_raw : t -> int -> unit

Assignment Functions



C documentation
val set : t -> t -> round -> int
val set_si : t -> int -> round -> int
val set_d : t -> float -> round -> int
val set_z : t -> Mpz.t -> round -> int
val set_q : t -> Mpq.t -> round -> int
val _set_str : t -> string -> int -> round -> unit
val set_str : t -> string -> base:int -> round -> unit
val set_f : t -> Mpf.t -> 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 : t -> round -> int * t
val init_set_si : int -> round -> int * t
val init_set_d : float -> round -> int * t
val init_set_f : Mpf.t -> round -> int * t
val init_set_z : Mpz.t -> round -> int * t
val init_set_q : Mpq.t -> round -> int * t
val _init_set_str : string -> int -> round -> t
val init_set_str : string -> base:int -> round -> t

Conversion Functions



C documentation
val get_d : t -> round -> float
val get_d1 : t -> float
val get_z_exp : Mpz.t -> t -> int
val get_z : Mpz.t -> t -> round -> unit
val _get_str : int -> int -> t -> 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 : t -> string
val to_float : ?round:round -> t -> float
val to_mpq : t -> Mpq.t
val of_string : string -> round -> t
val of_float : float -> round -> t
val of_int : int -> round -> t
val of_frac : int -> int -> round -> t
val of_mpz : Mpz.t -> round -> t
val of_mpz2 : Mpz.t -> Mpz.t -> round -> t
val of_mpq : Mpq.t -> round -> t

Basic Arithmetic Functions



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

Comparison Functions



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

Special Functions



C documentation
val log : t -> t -> round -> int
val log2 : t -> t -> round -> int
val log10 : t -> t -> round -> int
val exp : t -> t -> round -> int
val exp2 : t -> t -> round -> int
val exp10 : t -> t -> round -> int
val cos : t -> t -> round -> int
val sin : t -> t -> round -> int
val tan : t -> t -> round -> int
val sec : t -> t -> round -> int
val csc : t -> t -> round -> int
val cot : t -> t -> round -> int
val sin_cos : t -> t -> t -> round -> bool
val acos : t -> t -> round -> int
val asin : t -> t -> round -> int
val atan : t -> t -> round -> int
val atan2 : t -> t -> t -> round -> int
val cosh : t -> t -> round -> int
val sinh : t -> t -> round -> int
val tanh : t -> t -> round -> int
val sech : t -> t -> round -> int
val csch : t -> t -> round -> int
val coth : t -> t -> round -> int
val acosh : t -> t -> round -> int
val asinh : t -> t -> round -> int
val atanh : t -> t -> round -> int
val fac_ui : t -> int -> round -> int
val log1p : t -> t -> round -> int
val expm1 : t -> t -> round -> int
val eint : t -> t -> round -> int
val gamma : t -> t -> round -> int
val lngamma : t -> t -> round -> int
val zeta : t -> t -> round -> int
val erf : t -> t -> round -> int
val erfc : t -> t -> round -> int
val fma : t -> t -> t -> t -> round -> int
val agm : t -> t -> t -> round -> int
val hypot : t -> t -> t -> 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 -> t -> round -> int
val ceil : t -> t -> int
val floor : t -> t -> int
val round : t -> t -> int
val trunc : t -> t -> int
val integer_p : t -> bool
val nexttoward : t -> t -> unit
val nextabove : t -> unit
val nextbelow : t -> unit
val min : t -> t -> t -> round -> int
val max : t -> t -> t -> round -> int
val get_exp : t -> int
val set_exp : t -> int -> int