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
9namespace cln {
10
11// Undocumented 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
28extern 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")
34extern const cl_F read_float (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse);
35extern const cl_F read_float (std::istream& stream, const cl_read_flags& flags);
36
37// Documented input functions
38
39inline std::istream& operator>> (std::istream& stream, cl_F& result)
40{
41 extern cl_read_flags cl_F_read_flags;
42 result = read_float(stream,cl_F_read_flags);
43 return stream;
44}
45
46
47// Undocumented output functions
48
49
50// Documented output functions
51
52// Gibt ein Float aus.
53// print_float(stream,z);
54// > z: Float
55// > stream: Stream
56extern void print_float (std::ostream& stream, const cl_print_flags& flags, const cl_F& z);
57extern void print_float (std::ostream& stream, const cl_print_number_flags& flags, const cl_F& z);
58extern void print_float (std::ostream& stream, const cl_print_real_flags& flags, const cl_F& z);
59extern void print_float (std::ostream& stream, const cl_print_float_flags& flags, const cl_F& z);
60
61// Gibt ein Float binär (sehr primitiv) aus.
62// print_float_binary(stream,z);
63// > z: Float
64// > stream: Stream
65extern void print_float_binary (std::ostream& stream, const cl_F& z);
66
67// The following does strictly the same as the general `fprint' for numbers.
68// It is here only so that you don't need the complex printer
69// in order to print a float. ("Treeshaking")
70
71inline void fprint (std::ostream& stream, const cl_F& x)
72{
73 extern cl_print_flags default_print_flags;
74 print_float(stream,default_print_flags,x);
75}
76
77CL_DEFINE_PRINT_OPERATOR(cl_F)
78
79} // namespace cln
80
81#endif /* _CL_FLOAT_IO_H */
82