4 #include "base/cl_sysdep.h"
7 #include "float/cl_F.h"
12 #include "float/lfloat/cl_LF.h"
13 #include "float/lfloat/cl_LF_impl.h"
14 #include "float/dfloat/cl_DF.h"
15 #include "base/digitseq/cl_DS.h"
19 const cl_DF cl_LF_to_DF (const cl_LF& x)
26 LF_decode(x, { return cl_DF_0; }, sign=,exp=,ptr=,len=,);
27 // intDsize*len-DF_mant_len-1 Bits der Mantisse wegrunden:
28 // erste k := ceiling(DF_mant_len+2,intDsize) Digits nach manthi,mantlo holen:
29 var const int shiftcount = ceiling(DF_mant_len+2,intDsize)*intDsize-(DF_mant_len+1);
30 #if (cl_word_size==64)
31 var uint64 mant = get_max64_Dptr(DF_mant_len+2,ptr);
32 ptr = ptr mspop ceiling(DF_mant_len+2,intDsize);
33 if ( ((mant & bit(shiftcount-1)) ==0) // Bit 10 war 0 -> abrunden
34 || ( ((mant & (bit(shiftcount-1)-1)) ==0) // war 1, Bits 9..0 >0 -> aufrunden
35 && !test_loop_msp(ptr,len-ceiling(DF_mant_len+2,intDsize)) // weitere Bits /=0 -> aufrunden
37 && ((mant & bit(shiftcount)) ==0)
40 { mant = mant >> shiftcount; }
43 { mant = mant >> shiftcount;
45 if (mant >= bit(DF_mant_len+1))
46 // Überlauf durchs Runden
47 { mant = mant>>1; exp = exp+1; } // Mantisse rechts schieben
49 return encode_DF(sign,exp,mant);
51 var uint32 manthi = get_max32_Dptr(DF_mant_len+2-32,ptr);
52 var uint32 mantlo = get_32_Dptr(ptr mspop ceiling(DF_mant_len+2-32,intDsize));
53 ptr = ptr mspop ceiling(DF_mant_len+2,intDsize);
54 if ( ((mantlo & bit(shiftcount-1)) ==0) // Bit 10 war 0 -> abrunden
55 || ( ((mantlo & (bit(shiftcount-1)-1)) ==0) // war 1, Bits 9..0 >0 -> aufrunden
56 && !test_loop_msp(ptr,len-ceiling(DF_mant_len+2,intDsize)) // weitere Bits /=0 -> aufrunden
58 && ((mantlo & bit(shiftcount)) ==0)
61 { mantlo = (manthi << (32-shiftcount)) | (mantlo >> shiftcount);
62 manthi = manthi >> shiftcount;
66 { mantlo = (manthi << (32-shiftcount)) | (mantlo >> shiftcount);
67 manthi = manthi >> shiftcount;
71 if (manthi >= bit(DF_mant_len+1-32))
72 // Überlauf durchs Runden
73 { manthi = manthi>>1; exp = exp+1; } // Mantisse rechts schieben
75 return encode_DF(sign,exp,manthi,mantlo);