You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.7 KiB

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