Node:C++ Formatted Output, Previous:Formatted Output Functions, Up:Formatted Output
The following functions are provided in libgmpxx
, which is built if C++
support is enabled (see Build Options). Prototypes are available from
<gmp.h>
.
ostream& operator<< (ostream& stream, mpz_t op) | Function |
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 |
ostream& operator<< (ostream& stream, mpq_t op) | Function |
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 In hex or octal, op is printed as a signed value, the same as for
decimal. If |
ostream& operator<< (ostream& stream, mpf_t op) | Function |
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
|
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, see C++ Formatted Input) is the only overloading available and using for instance
+
with an mpz_t
will have unpredictable results.