Module Mpf


module Mpf: sig .. end
GMP multiprecision floating-point numbers

type t 

GMP 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

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

Assignement Functions



C documentation
val set : t -> t -> unit
val set_si : t -> int -> unit
val set_d : t -> float -> unit
val set_z : t -> Mpz.t -> unit
val set_q : t -> Mpq.t -> unit
val _set_str : t -> string -> int -> unit
val set_str : t -> string -> base:int -> unit
val swap : t -> t -> unit

Combined Initialization and Assignement Functions



C documentation
val init_set : t -> t
val init_set_si : int -> t
val init_set_d : float -> t
val _init_set_str : string -> int -> t
val init_set_str : string -> base:int -> t

Conversion Functions



C documentation
val get_d : t -> float
val get_d_2exp : t -> float * int
val get_si : t -> nativeint
val get_int : t -> int
val get_z : Mpz.t -> t -> unit
val get_q : Mpq.t -> t -> unit
val _get_str : int -> int -> t -> string * int
val get_str : base:int -> digits:int -> t -> 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 : t -> float
val of_string : string -> t
val of_float : float -> t
val of_int : int -> t
val of_mpz : Mpz.t -> t
val of_mpq : Mpq.t -> t
val is_integer : t -> bool

Arithmetic Functions



C documentation
val add : t -> t -> t -> unit
val add_ui : t -> t -> int -> unit
val sub : t -> t -> t -> unit
val ui_sub : t -> int -> t -> unit
val sub_ui : t -> t -> int -> unit
val mul : t -> t -> t -> unit
val mul_ui : t -> t -> int -> unit
val mul_2exp : t -> t -> int -> unit
val div : t -> t -> t -> unit
val ui_div : t -> int -> t -> unit
val div_ui : t -> t -> int -> unit
val div_2exp : t -> t -> int -> unit
val sqrt : t -> t -> unit
val pow_ui : t -> t -> int -> unit
val neg : t -> t -> unit
val abs : t -> t -> unit

Comparison Functions



C documentation
val cmp : t -> t -> int
val cmp_d : t -> float -> int
val cmp_si : t -> int -> int
val sgn : t -> int
val _equal : t -> t -> int -> bool
val equal : t -> t -> bits:int -> bool
val reldiff : t -> t -> t -> unit

Input and Output Functions: not interfaced



Random Number Functions: see Gmp_random module



Miscellaneous Float Functions



C documentation
val ceil : t -> t -> unit
val floor : t -> t -> unit
val trunc : t -> t -> unit
val integer_p : t -> bool
val fits_int_p : t -> bool
val fits_ulong_p : t -> bool
val fits_slong_p : t -> bool
val fits_uint_p : t -> bool
val fits_sint_p : t -> bool
val fits_ushort_p : t -> bool
val fits_sshort_p : t -> bool