]> www.ginac.de Git - cln.git/blob - src/float/dfloat/misc/cl_DF_idecode.cc
* Removed internal gmp/ directory and other traces of it like $GMP_INCLUDES.
[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 "cl_dfloat.h"
8
9
10 // Implementation.
11
12 #include "cl_DF.h"
13 #include "cl_I.h"
14
15 MAYBE_INLINE
16 const cl_idecoded_float integer_decode_float (const cl_DF& x)
17 {
18         // x entpacken:
19         var cl_signean sign;
20         var sintL exp;
21 #if (cl_word_size==64)
22         var uint64 mant;
23         DF_decode(x, { return cl_idecoded_float(0, 0, 1); },
24                      sign=,exp=,mant=
25                  );
26         return cl_idecoded_float(
27                 Q_to_I(mant), // Mantisse (>0, <2^53) als Bignum
28                 L_to_FN(exp-(DF_mant_len+1)), // e-53 als Fixnum
29                 (sign>=0 ? cl_I(1) : cl_I(-1)) // (-1)^s erzeugen
30                );
31 #else
32         var uint32 manthi;
33         var uint32 mantlo;
34         DF_decode2(x, { return cl_idecoded_float(0, 0, 1); },
35                       sign=,exp=,manthi=,mantlo=
36                   );
37         return cl_idecoded_float(
38                 L2_to_I(manthi,mantlo), // Mantisse (>0, <2^53) als Bignum
39                 L_to_FN(exp-(DF_mant_len+1)), // e als Fixnum
40                 (sign>=0 ? cl_I(1) : cl_I(-1)) // (-1)^s erzeugen
41                );
42 #endif
43 }