1 // print_rational().
2
3 // General includes.
4 #include "base/cl_sysdep.h"
5
6 // Specification.
7 #include "cln/rational_io.h"
8
9
10 // Implementation.
11
12 #include "cln/integer_io.h"
13 #include "cln/rational.h"
14 #include "rational/cl_RA.h"
15
16 namespace cln {
17
print_rational(std::ostream & stream,unsigned int base,const cl_RA & z)18 void print_rational (std::ostream& stream, unsigned int base, const cl_RA& z)
19 {
20 if (integerp(z)) {
21 DeclareType(cl_I,z);
22 print_integer(stream,base,z);
23 } else {
24 DeclareType(cl_RT,z);
25 var const cl_I& num = numerator(z);
26 var const cl_I& den = denominator(z);
27 // Der Zähler trägt das Vorzeichen.
28 print_integer(stream,base,num); // Zähler ausgeben
29 fprintchar(stream,'/');
30 print_integer(stream,base,den); // Nenner ausgeben
31 }
32 }
33
34 } // namespace cln
35