]> www.ginac.de Git - cln.git/blob - src/float/output/cl_F_printb.cc
fb0b598a653fdd99c399de9185b188efc436677d
[cln.git] / src / float / output / cl_F_printb.cc
1 // print_float_binary().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_float_io.h"
8
9
10 // Implementation.
11
12 #include "cl_float.h"
13 #include "cl_F.h"
14 #include "cl_integer_io.h"
15 #include "cl_I.h"
16
17 void print_float_binary (cl_ostream stream, const cl_F& z)
18 {
19 // Vorzeichen, Punkt, Mantisse (binär), (Zweiersystem-)Exponent (dezimal)
20         cl_idecoded_float m_e_s = integer_decode_float(z);
21         var cl_I& m = m_e_s.mantissa;
22         var cl_I& s = m_e_s.sign;
23         // Vorzeichen ausgeben, falls <0:
24         if (eq(s,-1))
25                 fprintchar(stream,'-');
26         // Mantisse binär(!) ausgeben:
27         fprintchar(stream,'.');
28         print_integer(stream,2,m);
29         // Exponent-Marker ausgeben:
30         {
31                 var char exp_marker;
32                 floattypecase(z
33                 ,       exp_marker = 's';
34                 ,       exp_marker = 'f';
35                 ,       exp_marker = 'd';
36                 ,       exp_marker = 'L';
37                 );
38                 fprintchar(stream,exp_marker);
39         }
40         // Exponenten dezimal ausgeben:
41         print_integer(stream,10,cl_I(float_exponent(z)));
42 }