1 // I/O of rational numbers.
3 #ifndef _CL_RATIONAL_IO_H
4 #define _CL_RATIONAL_IO_H
6 #include "cln/number_io.h"
7 #include "cln/rational.h"
13 // Wandelt eine Zeichenkette mit Rational-Syntax in eine rationale Zahl um.
14 // read_rational(base,sign,string,index1,index3,index2)
15 // > base: Lesebasis (>=2, <=36)
16 // > sign: Vorzeichen (/=0 falls negativ)
17 // > string: Simple-String (enthält Ziffern mit Wert <base und Bruchstrich)
18 // > index1: Index der ersten Ziffer
19 // > index3: Index von '/'
20 // > index2: Index nach der letzten Ziffer
21 // (also index3-index1 Zähler-Ziffern, index2-index3-1 Nenner-Ziffern)
22 // < ergebnis: rationale Zahl
23 extern const cl_RA read_rational (unsigned int base,
24 cl_signean sign, const char * string, uintC index1, uintC index3, uintC index2);
26 // The following does strictly the same as the general read_complex.
27 // It is here only so that you don't need the complex and float number
28 // readers in order to read an rational number. ("Treeshaking")
29 extern const cl_RA read_rational (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse);
30 extern const cl_RA read_rational (std::istream& stream, const cl_read_flags& flags);
32 inline std::istream& operator>> (std::istream& stream, cl_RA& result)
34 extern cl_read_flags cl_RA_read_flags;
35 result = read_rational(stream,cl_RA_read_flags);
42 // Gibt eine rationale Zahl aus.
43 // print_rational(stream,base,z);
44 // > z: rationale Zahl
45 // > base: Basis (>=2, <=36)
47 extern void print_rational (std::ostream& stream, unsigned int base, const cl_RA& z);
49 // Gibt eine Zahl aus.
50 // print_rational(stream,flags,z);
53 // > flags: Ausgabe-Parameter
54 extern void print_rational (std::ostream& stream, const cl_print_flags& flags, const cl_RA& z);
55 extern void print_rational (std::ostream& stream, const cl_print_number_flags& flags, const cl_RA& z);
56 extern void print_rational (std::ostream& stream, const cl_print_real_flags& flags, const cl_RA& z);
57 extern void print_rational (std::ostream& stream, const cl_print_rational_flags& flags, const cl_RA& z);
59 // The following does strictly the same as the general `fprint' for numbers.
60 // It is here only so that you don't need the complex and long-float number
61 // printers in order to print an integer. ("Treeshaking")
63 inline void fprint (std::ostream& stream, const cl_RA& x)
65 extern cl_print_flags default_print_flags;
66 print_rational(stream,default_print_flags,x);
69 CL_DEFINE_PRINT_OPERATOR(cl_RA)
73 #endif /* _CL_RATIONAL_IO_H */