4 #include "base/cl_sysdep.h"
7 #include "float/cl_F.h"
12 #include "float/ffloat/cl_FF.h"
13 #include "float/sfloat/cl_SF.h"
17 const cl_SF cl_FF_to_SF (const cl_FF& x)
23 FF_decode(x, { return SF_0; }, sign=,exp=,mant=);
24 // 23-16 Bits wegrunden:
25 var const int shiftcount = FF_mant_len-SF_mant_len;
26 if ( ((mant & bit(shiftcount-1)) ==0) // Bit 6 war 0 -> abrunden
27 || ( ((mant & (bit(shiftcount-1)-1)) ==0) // war 1, Bits 5..0 >0 -> aufrunden
29 && ((mant & bit(shiftcount)) ==0)
32 { mant = mant >> shiftcount; }
35 { mant = mant >> shiftcount;
37 if (mant >= bit(SF_mant_len+1))
38 // Überlauf durchs Runden
39 { mant = mant>>1; exp = exp+1; } // Mantisse rechts schieben
41 return encode_SF(sign,exp,mant);