Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-19 08:08:32

0001 // I/O of rational numbers.
0002 
0003 #ifndef _CL_RATIONAL_IO_H
0004 #define _CL_RATIONAL_IO_H
0005 
0006 #include "cln/number_io.h"
0007 #include "cln/rational.h"
0008 
0009 namespace cln {
0010 
0011 // Input functions
0012 
0013 // Wandelt eine Zeichenkette mit Rational-Syntax in eine rationale Zahl um.
0014 // read_rational(base,sign,string,index1,index3,index2)
0015 // > base: Lesebasis (>=2, <=36)
0016 // > sign: Vorzeichen (/=0 falls negativ)
0017 // > string: Simple-String (enthält Ziffern mit Wert <base und Bruchstrich)
0018 // > index1: Index der ersten Ziffer
0019 // > index3: Index von '/'
0020 // > index2: Index nach der letzten Ziffer
0021 //   (also index3-index1 Zähler-Ziffern, index2-index3-1 Nenner-Ziffern)
0022 // < ergebnis: rationale Zahl
0023 extern const cl_RA read_rational (unsigned int base,
0024                    cl_signean sign, const char * string, uintC index1, uintC index3, uintC index2);
0025 
0026 // The following does strictly the same as the general read_complex.
0027 // It is here only so that you don't need the complex and float number
0028 // readers in order to read an rational number. ("Treeshaking")
0029 extern const cl_RA read_rational (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse);
0030 extern const cl_RA read_rational (std::istream& stream, const cl_read_flags& flags);
0031 
0032 inline std::istream& operator>> (std::istream& stream, cl_RA& result)
0033 {
0034     extern cl_read_flags cl_RA_read_flags;
0035     result = read_rational(stream,cl_RA_read_flags);
0036     return stream;
0037 }
0038 
0039 
0040 // Output functions
0041 
0042 // Gibt eine rationale Zahl aus.
0043 // print_rational(stream,base,z);
0044 // > z: rationale Zahl
0045 // > base: Basis (>=2, <=36)
0046 // > stream: Stream
0047 extern void print_rational (std::ostream& stream, unsigned int base, const cl_RA& z);
0048 
0049 // Gibt eine Zahl aus.
0050 // print_rational(stream,flags,z);
0051 // > z: Zahl
0052 // > stream: Stream
0053 // > flags: Ausgabe-Parameter
0054 extern void print_rational (std::ostream& stream, const cl_print_flags& flags, const cl_RA& z);
0055 extern void print_rational (std::ostream& stream, const cl_print_number_flags& flags, const cl_RA& z);
0056 extern void print_rational (std::ostream& stream, const cl_print_real_flags& flags, const cl_RA& z);
0057 extern void print_rational (std::ostream& stream, const cl_print_rational_flags& flags, const cl_RA& z);
0058 
0059 // The following does strictly the same as the general `fprint' for numbers.
0060 // It is here only so that you don't need the complex and long-float number
0061 // printers in order to print an integer. ("Treeshaking")
0062 
0063 inline void fprint (std::ostream& stream, const cl_RA& x)
0064 {
0065     extern cl_print_flags default_print_flags;
0066     print_rational(stream,default_print_flags,x);
0067 }
0068 
0069 CL_DEFINE_PRINT_OPERATOR(cl_RA)
0070 
0071 }  // namespace cln
0072 
0073 #endif /* _CL_RATIONAL_IO_H */