C++ Formatted Output
====================
The following functions are provided in `libgmpxx', which is built
if C++ support is enabled (Note:Build Options). Prototypes are
available from `<gmp.h>'.
- Function: ostream& operator<< (ostream& STREAM, mpz_t OP)
Print OP to STREAM, using its `ios' formatting settings.
`ios::width' is reset to 0 after output, the same as the standard
`ostream operator<<' routines do.
In hex or octal, OP is printed as a signed number, the same as for
decimal. This is unlike the standard `operator<<' routines on
`int' etc, which instead give twos complement.
- Function: ostream& operator<< (ostream& STREAM, mpq_t OP)
Print OP to STREAM, using its `ios' formatting settings.
`ios::width' is reset to 0 after output, the same as the standard
`ostream operator<<' routines do.
Output will be a fraction like `5/9', or if the denominator is 1
then just a plain integer like `123'.
In hex or octal, OP is printed as a signed value, the same as for
decimal. If `ios::showbase' is set then a base indicator is shown
on both the numerator and denominator (if the denominator is
required).
- Function: ostream& operator<< (ostream& STREAM, mpf_t OP)
Print OP to STREAM, using its `ios' formatting settings.
`ios::width' is reset to 0 after output, the same as the standard
`ostream operator<<' routines do. The decimal point follows the
current locale, on systems providing `localeconv'.
Hex and octal are supported, unlike the standard `operator<<'
routines on `double' etc. The mantissa will be in hex or octal,
the exponent will be in decimal. For hex the exponent delimiter
is an `@'. This is as per `mpf_out_str'. `ios::showbase' is
supported, and will put a base on the mantissa.
These operators mean that GMP types can be printed in the usual C++
way, for example,
mpz_t z;
int n;
...
cout << "iteration " << n << " value " << z << "\n";
But note that `ostream' output (and `istream' input, Note:C++
Formatted Input) is the only overloading available and using for
instance `+' with an `mpz_t' will have unpredictable results.