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.

81 lines
2.8 KiB

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