GNU Info

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

(gmp.info)C++ Interface Rationals


Next: C++ Interface Floats Prev: C++ Interface Integers Up: C++ Class Interface
Enter node , (file) or (file)node

C++ Interface Rationals
=======================

   In all the following constructors, if a fraction is given then it
should be in canonical form, or if not then `mpq_class::canonicalize'
called.

 - Function: void mpq_class::mpq_class (type OP)
 - Function: void mpq_class::mpq_class (integer NUM, integer DEN)
     Construct an `mpq_class'.  The initial value can be a single value
     of any type, or a pair of integers (`mpz_class' or standard C++
     integer types) representing a fraction, except that `long long'
     and `long double' are not supported.  For example,

          mpq_class q (99);
          mpq_class q (1.75);
          mpq_class q (1, 3);

 - Function: void mpq_class::mpq_class (mpq_t Q)
     Construct an `mpq_class' from an `mpq_t'.  The value in Q is
     copied into the new `mpq_class', there won't be any permanent
     association between it and Q.

 - Function: void mpq_class::mpq_class (const char *S)
 - Function: void mpq_class::mpq_class (const char *S, int base)
 - Function: void mpq_class::mpq_class (const string& S)
 - Function: void mpq_class::mpq_class (const string& S, int base)
     Construct an `mpq_class' converted from a string using
     `mpq_set_str', (Note: Initializing Rationals).  If the BASE is
     not given then 0 is used.

 - Function: void mpq_class::canonicalize ()
     Put an `mpq_class' into canonical form, as per Note: Rational
     Number Functions.  All arithmetic operators require their
     operands in canonical form, and will return results in canonical
     form.

 - Function: mpq_class abs (mpq_class OP)
 - Function: int cmp (mpq_class OP1, type OP2)
 - Function: int cmp (type OP1, mpq_class OP2)
 - Function: double mpq_class::get_d (void)
 - Function: int sgn (mpq_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'.

 - Function: mpz_class& mpq_class::get_num ()
 - Function: mpz_class& mpq_class::get_den ()
     Get a reference to an `mpz_class' which is the numerator or
     denominator of an `mpq_class'.  This can be used both for read and
     write access.  If the object returned is modified, it modifies the
     original `mpq_class'.

     If direct manipulation might produce a non-canonical value, then
     `mpq_class::canonicalize' must be called before further operations.

 - Function: mpz_t mpq_class::get_num_mpz_t ()
 - Function: mpz_t mpq_class::get_den_mpz_t ()
     Get a reference to the underlying `mpz_t' numerator or denominator
     of an `mpq_class'.  This can be passed to C functions expecting an
     `mpz_t'.  Any modifications made to the `mpz_t' will modify the
     original `mpq_class'.

     If direct manipulation might produce a non-canonical value, then
     `mpq_class::canonicalize' must be called before further operations.

 - Function: istream& operator>> (istream& STREAM, mpq_class& ROP);
     Read ROP from STREAM, using its `ios' formatting settings, the
     same as `mpq_t operator>>' (Note: C++ Formatted Input).

     If the ROP read might not be in canonical form then
     `mpq_class::canonicalize' must be called.


automatically generated by info2www version 1.2.2.9