]> www.ginac.de Git - cln.git/blob - src/float/dfloat/misc/cl_DF_idecode.cc
* include/cln/number.h (As): Fix it in namespace by suffixing `_As'
[cln.git] / src / float / dfloat / misc / cl_DF_idecode.cc
1 // integer_decode_float().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/dfloat.h"
8
9
10 // Implementation.
11
12 #include "cl_DF.h"
13 #include "cl_I.h"
14
15 namespace cln {
16
17 MAYBE_INLINE
18 const cl_idecoded_float integer_decode_float (const cl_DF& x)
19 {
20         // x entpacken:
21         var cl_signean sign;
22         var sintL exp;
23 #if (cl_word_size==64)
24         var uint64 mant;
25         DF_decode(x, { return cl_idecoded_float(0, 0, 1); },
26                      sign=,exp=,mant=
27                  );
28         return cl_idecoded_float(
29                 Q_to_I(mant), // Mantisse (>0, <2^53) als Bignum
30                 L_to_FN(exp-(DF_mant_len+1)), // e-53 als Fixnum
31                 (sign>=0 ? cl_I(1) : cl_I(-1)) // (-1)^s erzeugen
32                );
33 #else
34         var uint32 manthi;
35         var uint32 mantlo;
36         DF_decode2(x, { return cl_idecoded_float(0, 0, 1); },
37                       sign=,exp=,manthi=,mantlo=
38                   );
39         return cl_idecoded_float(
40                 L2_to_I(manthi,mantlo), // Mantisse (>0, <2^53) als Bignum
41                 L_to_FN(exp-(DF_mant_len+1)), // e als Fixnum
42                 (sign>=0 ? cl_I(1) : cl_I(-1)) // (-1)^s erzeugen
43                );
44 #endif
45 }
46
47 }  // namespace cln