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