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