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.

79 lines
2.8 KiB

25 years ago
  1. // I/O of floats.
  2. #ifndef _CL_FLOAT_IO_H
  3. #define _CL_FLOAT_IO_H
  4. #include "cl_number_io.h"
  5. #include "cl_float.h"
  6. // Undocumented input functions
  7. // Wandelt eine Zeichenkette mit Float-Syntax in ein Float um.
  8. // read_float(base,sign,string,index1,index4,index2,index3)
  9. // > base: Lesebasis (=10)
  10. // > sign: Vorzeichen (/=0 falls negativ)
  11. // > string: Simple-String (enth�lt Ziffern und evtl. Punkt und Exponentmarker)
  12. // > index1: Index vom Mantissenanfang (excl. Vorzeichen)
  13. // > index4: Index nach dem Mantissenende
  14. // > index2: Index beim Ende der Characters
  15. // > index3: Index nach dem Dezimalpunkt (=index4 falls keiner da)
  16. // (also Mantisse mit index4-index1 Characters: Ziffern und max. 1 '.')
  17. // (also index4-index3 Nachkommaziffern)
  18. // (also bei index4<index2: index4 = Index des Exponent-Markers,
  19. // index4+1 = Index des Exponenten-Vorzeichens oder der ersten
  20. // Exponenten-Ziffer)
  21. // < ergebnis: Float
  22. extern const cl_F read_float (unsigned int base, cl_float_format_t prec,
  23. cl_signean sign, const char * string, uintL index1, uintL index4, uintL index2, uintL index3);
  24. // The following does strictly the same as the general read_complex.
  25. // It is here only so that you don't need the complex and rational number
  26. // readers in order to read a float number. ("Treeshaking")
  27. extern const cl_F read_float (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse);
  28. extern const cl_F read_float (cl_istream stream, const cl_read_flags& flags);
  29. // Documented input functions
  30. inline cl_istream operator>> (cl_istream stream, cl_F& result)
  31. {
  32. extern cl_read_flags cl_F_read_flags;
  33. result = read_float(stream,cl_F_read_flags);
  34. return stream;
  35. }
  36. // Undocumented output functions
  37. // Documented output functions
  38. // Gibt ein Float aus.
  39. // print_float(stream,z);
  40. // > z: Float
  41. // > stream: Stream
  42. extern void print_float (cl_ostream stream, const cl_print_flags& flags, const cl_F& z);
  43. extern void print_float (cl_ostream stream, const cl_print_number_flags& flags, const cl_F& z);
  44. extern void print_float (cl_ostream stream, const cl_print_real_flags& flags, const cl_F& z);
  45. extern void print_float (cl_ostream stream, const cl_print_float_flags& flags, const cl_F& z);
  46. // Gibt ein Float bin�r (sehr primitiv) aus.
  47. // print_float_binary(stream,z);
  48. // > z: Float
  49. // > stream: Stream
  50. extern void print_float_binary (cl_ostream stream, const cl_F& z);
  51. // The following does strictly the same as the general `fprint' for numbers.
  52. // It is here only so that you don't need the complex printer
  53. // in order to print a float. ("Treeshaking")
  54. inline void fprint (cl_ostream stream, const cl_F& x)
  55. {
  56. extern cl_print_flags cl_default_print_flags;
  57. print_float(stream,cl_default_print_flags,x);
  58. }
  59. CL_DEFINE_PRINT_OPERATOR(cl_F)
  60. #endif /* _CL_FLOAT_IO_H */