]> www.ginac.de Git - cln.git/blob - src/float/ffloat/misc/cl_FF_idecode.cc
Fix linking problems on some platforms caused by inline/non-inline versions
[cln.git] / src / float / ffloat / misc / cl_FF_idecode.cc
1 // integer_decode_float().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/ffloat.h"
8
9
10 // Implementation.
11
12 #include "cl_FF.h"
13 #include "cl_I.h"
14
15 #if defined(__mips__) && !defined(__GNUC__)
16
17 // Workaround SGI Irix 6.2 C++ 7.0 bug.
18
19 #include "cl_F.h"
20 #include "dfloat/cl_DF.h"
21
22 namespace cln {
23
24 CL_INLINE const cl_idecoded_float CL_INLINE_DECL(integer_decode_float) (const cl_FF& x)
25 {
26         var cl_idecoded_float sem = integer_decode_float(cl_FF_to_DF(x));
27         return cl_idecoded_float(sem.mantissa >> (DF_mant_len-FF_mant_len),
28                                  sem.exponent + (DF_mant_len-FF_mant_len),
29                                  sem.sign
30                                 );
31 }
32
33 }  // namespace cln
34
35 #else
36
37 namespace cln {
38
39 CL_INLINE const cl_idecoded_float CL_INLINE_DECL(integer_decode_float) (const cl_FF& x)
40 {
41         // x entpacken:
42         var cl_signean sign;
43         var sintL exp;
44         var uint32 mant;
45         FF_decode(x, { return cl_idecoded_float(0, 0, 1); },
46                      sign=,exp=,mant=
47                  );
48         return cl_idecoded_float(
49                 (FF_mant_len+1 < cl_value_len
50                  ? L_to_FN(mant) // Mantisse als Fixnum
51                  : UL_to_I(mant) // oder evtl. als Bignum
52                 ),
53                 L_to_FN(exp-(FF_mant_len+1)), // e-24 als Fixnum
54                 (sign>=0 ? cl_I(1) : cl_I(-1)) // (-1)^s erzeugen
55                );
56 }
57
58 }  // namespace cln
59
60 #endif