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.

76 lines
2.6 KiB

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