Module Mpf

module Mpf: sig .. end
GMP multi-precision floating-point numbers

type 'a tt 

GMP 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

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

Assignement Functions



C documentation
val set : t -> 'a tt -> unit
val set_si : t -> int -> unit
val set_d : t -> float -> unit
val set_z : t -> 'a Mpz.tt -> unit
val set_q : t -> 'a Mpq.tt -> 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 : 'a tt -> 'b tt
val init_set_si : int -> 'a tt
val init_set_d : float -> 'a tt
val _init_set_str : string -> int -> 'a tt
val init_set_str : string -> base:int -> 'a tt

Conversion Functions



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

Arithmetic Functions



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

Comparison Functions



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

Input and Output Functions: not interfaced



Random Number Functions: see Gmp_random module



Miscellaneous Float Functions



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