- added I/O to Gmpz, Gmpq, in particular mentioning the possibility of

reading into a Gmpq from a floating-point value
This commit is contained in:
Bernd Gärtner 2007-03-06 15:49:57 +00:00
parent 16fe68293d
commit e32acbffa5
2 changed files with 13 additions and 1 deletions

View File

@ -66,6 +66,13 @@ number based on the {\sc Gnu} Multiple Precision Arithmetic Library.
%SetThreeColumns{std::ostream& }{}{\hspace*{8cm}}
\ccOperations
\ccFunction{std::ostream& operator<<(std::ostream& out, const Gmpq& q);}
{writes \ccc{q} to the ostream \ccc{out}, in the form $n/d$.}
\ccFunction{std::istream& operator>>(std::istream& in, Gmpq& q);}
{reads a number from \ccc{in}, then converts it to a \ccc{Gmpq}. The
number may be an integer, a rational number in the form $n/d$, or a
floating-point number.}
There are two access functions, namely to the
numerator and the denominator of a rational.
@ -77,7 +84,6 @@ if \ccStyle{q.numerator()} and \ccStyle{q.denominator()} are called
consecutively wrt. \ccStyle{q}, i.e.~\ccStyle{q} is not involved in
any other operation between these calls.
\ccMethod{Gmpz numerator() const;}
{returns the numerator of \ccStyle{q}.}
\ccGlue

View File

@ -30,6 +30,12 @@ based on the {\sc Gnu} Multiple Precision Arithmetic Library.
{creates a multiple-precision integer initialized with
the integral part of \ccStyle{d}.}
\ccOperations
\ccFunction{std::ostream& operator<<(std::ostream& out, const Gmpz& z);}
{writes \ccc{z} to the ostream \ccc{out}.}
\ccFunction{std::istream& operator>>(std::istream& in, Gmpz& z);}
{reads an integer from \ccc{in}, then converts it to a \ccc{Gmpz}.}
\ccImplementation
\ccc{Gmpz}s are reference counted.