]> www.ginac.de Git - cln.git/blob - src/float/lfloat/misc/cl_LF_idecode.cc
Fix linking problems on some platforms caused by inline/non-inline versions
[cln.git] / src / float / lfloat / misc / cl_LF_idecode.cc
1 // integer_decode_float().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cln/lfloat.h"
8
9
10 // Implementation.
11
12 #include "cl_LF.h"
13 #include "cl_I.h"
14 #include "cl_DS.h"
15
16 namespace cln {
17
18 CL_INLINE const cl_idecoded_float CL_INLINE_DECL(integer_decode_float) (const cl_LF& x)
19 {
20         // x entpacken:
21         var uintE uexp = TheLfloat(x)->expo;
22         if (uexp == 0)
23                 { return cl_idecoded_float(0, 0, 1); }
24         var cl_signean sign = TheLfloat(x)->sign;
25         var uintC len = TheLfloat(x)->len;
26         // intDsize*len >= 53 >= 33 >= cl_value_len, also len >= bn_minlength.
27         // Baue Integer für die Mantisse.
28         // Vorne 1 Nulldigit, damit es eine NDS wird.
29         var Bignum mant = allocate_bignum(1+len);
30         mspref(arrayMSDptr(TheBignum(mant)->data,1+len),0) = 0;
31         copy_loop_msp(arrayMSDptr(TheLfloat(x)->data,len),arrayMSDptr(TheBignum(mant)->data,1+len) mspop 1,len); // NUDS kopieren
32         return cl_idecoded_float(
33                 // Mantisse
34                 mant,
35                 // e-intDsize*n = uexp-LF_exp_mid-intDsize*n als Integer
36                 minus(uexp, LF_exp_mid + intDsize*len),
37                 (sign>=0 ? cl_I(1) : cl_I(-1)) // (-1)^s erzeugen
38                );
39 }
40
41 }  // namespace cln