]> www.ginac.de Git - cln.git/blob - src/float/ffloat/misc/cl_FF_idecode.cc
Don't generate cln.texi from cln.tex any more.
[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 MAYBE_INLINE
25 const cl_idecoded_float integer_decode_float (const cl_FF& x)
26 {
27         var cl_idecoded_float sem = integer_decode_float(cl_FF_to_DF(x));
28         return cl_idecoded_float(sem.mantissa >> (DF_mant_len-FF_mant_len),
29                                  sem.exponent + (DF_mant_len-FF_mant_len),
30                                  sem.sign
31                                 );
32 }
33
34 }  // namespace cln
35
36 #else
37
38 namespace cln {
39
40 MAYBE_INLINE
41 const cl_idecoded_float integer_decode_float (const cl_FF& x)
42 {
43         // x entpacken:
44         var cl_signean sign;
45         var sintL exp;
46         var uint32 mant;
47         FF_decode(x, { return cl_idecoded_float(0, 0, 1); },
48                      sign=,exp=,mant=
49                  );
50         return cl_idecoded_float(
51                 (FF_mant_len+1 < cl_value_len
52                  ? L_to_FN(mant) // Mantisse als Fixnum
53                  : UL_to_I(mant) // oder evtl. als Bignum
54                 ),
55                 L_to_FN(exp-(FF_mant_len+1)), // e-24 als Fixnum
56                 (sign>=0 ? cl_I(1) : cl_I(-1)) // (-1)^s erzeugen
57                );
58 }
59
60 }  // namespace cln
61
62 #endif