GNU Info

Info Node: (gmp.info)C++ Interface Floats

(gmp.info)C++ Interface Floats


Next: C++ Interface MPFR Prev: C++ Interface Rationals Up: C++ Class Interface
Enter node , (file) or (file)node

C++ Interface Floats
====================

   When an expression requires the use of temporary intermediate
`mpf_class' values, like `f=g*h+x*y', those temporaries will have the
same precision as the destination `f'.  Explicit constructors can be
used if this doesn't suit.

 - Function:  mpf_class::mpf_class (type OP)
 - Function:  mpf_class::mpf_class (type OP, unsigned long PREC)
     Construct an `mpf_class'.  Any standard C++ type can be used,
     except `long long' and `long double', and any of the GMP C++
     classes can be used.

     If PREC is given, the initial precision is that value, in bits.  If
     PREC is not given, then the initial precision is determined by the
     type of OP given.  An `mpz_class', `mpq_class', string, or C++
     builtin type will give the default `mpf' precision (Note:
     Initializing Floats).  An `mpf_class' or expression will give
     the precision of that value.  The precision of a binary expression
     is the higher of the two operands.

          mpf_class f(1.5);        // default precision
          mpf_class f(1.5, 500);   // 500 bits (at least)
          mpf_class f(x);          // precision of x
          mpf_class f(abs(x));     // precision of x
          mpf_class f(-g, 1000);   // 1000 bits (at least)
          mpf_class f(x+y);        // greater of precisions of x and y

 - Function: mpf_class abs (mpf_class OP)
 - Function: mpf_class ceil (mpf_class OP)
 - Function: int cmp (mpf_class OP1, type OP2)
 - Function: int cmp (type OP1, mpf_class OP2)
 - Function: mpf_class floor (mpf_class OP)
 - Function: mpf_class hypot (mpf_class OP1, mpf_class OP2)
 - Function: double mpf_class::get_d (void)
 - Function: long mpf_class::get_si (void)
 - Function: unsigned long mpf_class::get_ui (void)
 - Function: bool mpf_class::fits_sint_p (void)
 - Function: bool mpf_class::fits_slong_p (void)
 - Function: bool mpf_class::fits_sshort_p (void)
 - Function: bool mpf_class::fits_uint_p (void)
 - Function: bool mpf_class::fits_ulong_p (void)
 - Function: bool mpf_class::fits_ushort_p (void)
 - Function: int sgn (mpf_class OP)
 - Function: mpf_class sqrt (mpf_class OP)
 - Function: mpf_class trunc (mpf_class OP)
     These functions provide a C++ class interface to the corresponding
     GMP C routines.

     `cmp' can be used with any of the classes or the standard C++
     types, except `long long' and `long double'.

     The accuracy provided by `hypot' is not currently guaranteed.

 - Function: unsigned long int mpf_class::get_prec ()
 - Function: void mpf_class::set_prec (unsigned long PREC)
 - Function: void mpf_class::set_prec_raw (unsigned long PREC)
     Get or set the current precision of an `mpf_class'.

     The restrictions described for `mpf_set_prec_raw' (Note:
     Initializing Floats) apply to `mpf_class::set_prec_raw'.  Note
     in particular that the `mpf_class' must be restored to it's
     allocated precision before being destroyed.  This must be done by
     application code, there's no automatic mechanism for it.


automatically generated by info2www version 1.2.2.9