Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-19 08:08:30

0001 // I/O of floats.
0002 
0003 #ifndef _CL_FLOAT_IO_H
0004 #define _CL_FLOAT_IO_H
0005 
0006 #include "cln/number_io.h"
0007 #include "cln/float.h"
0008 
0009 namespace cln {
0010 
0011 // Input functions
0012 
0013 // Wandelt eine Zeichenkette mit Float-Syntax in ein Float um.
0014 // read_float(base,sign,string,index1,index4,index2,index3)
0015 // > base: Lesebasis (=10)
0016 // > sign: Vorzeichen (/=0 falls negativ)
0017 // > string: Simple-String (enthält Ziffern und evtl. Punkt und Exponentmarker)
0018 // > index1: Index vom Mantissenanfang (excl. Vorzeichen)
0019 // > index4: Index nach dem Mantissenende
0020 // > index2: Index beim Ende der Characters
0021 // > index3: Index nach dem Dezimalpunkt (=index4 falls keiner da)
0022 //   (also Mantisse mit index4-index1 Characters: Ziffern und max. 1 '.')
0023 //   (also index4-index3 Nachkommaziffern)
0024 //   (also bei index4<index2: index4 = Index des Exponent-Markers,
0025 //    index4+1 = Index des Exponenten-Vorzeichens oder der ersten
0026 //    Exponenten-Ziffer)
0027 // < ergebnis: Float
0028 extern const cl_F read_float (unsigned int base, float_format_t prec,
0029                   cl_signean sign, const char * string, uintC index1, uintC index4, uintC index2, uintC index3);
0030 
0031 // The following does strictly the same as the general read_complex.
0032 // It is here only so that you don't need the complex and rational number
0033 // readers in order to read a float number. ("Treeshaking")
0034 extern const cl_F read_float (const cl_read_flags& flags, const char * string, const char * string_limit, const char * * end_of_parse);
0035 extern const cl_F read_float (std::istream& stream, const cl_read_flags& flags);
0036 
0037 inline std::istream& operator>> (std::istream& stream, cl_F& result)
0038 {
0039     extern cl_read_flags cl_F_read_flags;
0040     result = read_float(stream,cl_F_read_flags);
0041     return stream;
0042 }
0043 
0044 
0045 // Output functions
0046 
0047 // Gibt ein Float aus.
0048 // print_float(stream,z);
0049 // > z: Float
0050 // > stream: Stream
0051 extern void print_float (std::ostream& stream, const cl_print_flags& flags, const cl_F& z);
0052 extern void print_float (std::ostream& stream, const cl_print_number_flags& flags, const cl_F& z);
0053 extern void print_float (std::ostream& stream, const cl_print_real_flags& flags, const cl_F& z);
0054 extern void print_float (std::ostream& stream, const cl_print_float_flags& flags, const cl_F& z);
0055 
0056 // Gibt ein Float binär (sehr primitiv) aus.
0057 // print_float_binary(stream,z);
0058 // > z: Float
0059 // > stream: Stream
0060 extern void print_float_binary (std::ostream& stream, const cl_F& z);
0061 
0062 // The following does strictly the same as the general `fprint' for numbers.
0063 // It is here only so that you don't need the complex printer
0064 // in order to print a float. ("Treeshaking")
0065 
0066 inline void fprint (std::ostream& stream, const cl_F& x)
0067 {
0068     extern cl_print_flags default_print_flags;
0069     print_float(stream,default_print_flags,x);
0070 }
0071 
0072 CL_DEFINE_PRINT_OPERATOR(cl_F)
0073 
0074 }  // namespace cln
0075 
0076 #endif /* _CL_FLOAT_IO_H */