4 #include "base/cl_sysdep.h"
7 #include "float/lfloat/cl_LF.h"
12 #include "cln/integer.h"
13 #include "integer/cl_I.h"
14 #include "base/digitseq/cl_DS.h"
16 #include "base/cl_inline.h"
17 #include "float/lfloat/elem/cl_LF_minusp.cc"
21 const cl_I cl_LF_to_I (const cl_LF& x)
24 // Falls x=0.0, Ergebnis 0.
25 // Sonst (ASH Vorzeichen*Mantisse (e-16n)).
26 var uintE uexp = TheLfloat(x)->expo;
27 if (uexp==0) { return 0; } // x=0.0 -> Ergebnis 0
28 // Mantisse zu einem Integer machen:
32 var uintC len = TheLfloat(x)->len;
33 var uintC len1 = len+1; // brauche 1 Digit mehr
34 num_stack_alloc(len1, MSDptr=,LSDptr=);
35 copy_loop_msp(arrayMSDptr(TheLfloat(x)->data,len),MSDptr mspop 1,len); // Mantisse kopieren
36 mspref(MSDptr,0) = 0; // und zusätzliches Nulldigit
37 // Mantisse ist die UDS MSDptr/len1/LSDptr.
39 // x<0 -> Mantisse negieren:
40 { neg_loop_lsp(LSDptr,len1); }
41 // Vorzeichen*Mantisse ist die DS MSDptr/len1/LSDptr.
42 // (ASH Vorzeichen*Mantisse (- e 16n)) durchführen:
43 return ash(DS_to_I(MSDptr,len1),
44 minus(uexp, LF_exp_mid + intDsize*len)