]> www.ginac.de Git - cln.git/blob - include/cl_rational_io.h
Distinguish between cl_word_size and the ABI's pointer size.
[cln.git] / include / cl_rational_io.h
1 // I/O of rational numbers.
2
3 #ifndef _CL_RATIONAL_IO_H
4 #define _CL_RATIONAL_IO_H
5
6 #include "cl_number_io.h"
7 #include "cl_rational.h"
8
9
10 // Undocumented input functions
11
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);
24
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);
30
31 // Documented input functions
32
33 inline cl_istream operator>> (cl_istream stream, cl_RA& result)
34 {
35         extern cl_read_flags cl_RA_read_flags;
36         result = read_rational(stream,cl_RA_read_flags);
37         return stream;
38 }
39
40
41 // Undocumented output functions
42
43 // Gibt eine rationale Zahl aus.
44 // print_rational(stream,base,z);
45 // > z: rationale Zahl
46 // > base: Basis (>=2, <=36)
47 // > stream: Stream
48 extern void print_rational (cl_ostream stream, unsigned int base, const cl_RA& z);
49
50
51 // Documented output functions
52
53 // Gibt eine Zahl aus.
54 // print_rational(stream,flags,z);
55 // > z: Zahl
56 // > stream: Stream
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);
62
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")
66
67 inline void fprint (cl_ostream stream, const cl_RA& x)
68 {
69         extern cl_print_flags cl_default_print_flags;
70         print_rational(stream,cl_default_print_flags,x);
71 }
72
73 CL_DEFINE_PRINT_OPERATOR(cl_RA)
74
75
76 #endif /* _CL_RATIONAL_IO_H */