12 #include "cln/integer.h"
17 #define MAYBE_INLINE inline
18 #include "cl_LF_minusp.cc"
22 const cl_I cl_LF_to_I (const cl_LF& x)
25 // Falls x=0.0, Ergebnis 0.
26 // Sonst (ASH Vorzeichen*Mantisse (e-16n)).
27 var uintL uexp = TheLfloat(x)->expo;
28 if (uexp==0) { return 0; } // x=0.0 -> Ergebnis 0
29 // Mantisse zu einem Integer machen:
33 var uintC len = TheLfloat(x)->len;
34 var uintC len1 = len+1; // brauche 1 Digit mehr
35 num_stack_alloc(len1, MSDptr=,LSDptr=);
36 copy_loop_msp(arrayMSDptr(TheLfloat(x)->data,len),MSDptr mspop 1,len); // Mantisse kopieren
37 mspref(MSDptr,0) = 0; // und zusätzliches Nulldigit
38 // Mantisse ist die UDS MSDptr/len1/LSDptr.
40 // x<0 -> Mantisse negieren:
41 { neg_loop_lsp(LSDptr,len1); }
42 // Vorzeichen*Mantisse ist die DS MSDptr/len1/LSDptr.
43 // (ASH Vorzeichen*Mantisse (- e 16n)) durchführen:
44 return ash(DS_to_I(MSDptr,len1),
45 minus(uexp, LF_exp_mid + intDsize*len)