1 // cl_LF_shortenwith().
12 #include "cl_inline2.h"
13 #include "cl_LF_precision.cc"
14 #include "cl_inline.h"
15 #include "cl_LF_exponent.cc"
19 const cl_LF cl_LF_shortenwith (const cl_LF& x, const cl_LF& y)
22 // x = 0.0 -> Precision egal, return x.
23 // ex := float_exponent(x), dx := float_digits(x), 1 ulp(x) = 2^(ex-dx).
24 // ey := float_exponent(y).
25 // Falls ex-dx < ey, x von Precision dx auf ex-ey verkürzen.
26 var sintE ey = float_exponent_inline(y);
27 var sintE ex = float_exponent_inline(x);
28 var uintC dx = float_precision_inline(x);
29 if (dx==0) // zerop(x) ?
31 var sintE ulpx = ex - dx;
32 if ((ex<0 && ulpx>=0) // underflow?
34 ) { // Now ex-dx < ey, hence ex-ey < dx.
37 new_dx = intDsize*LF_minlen;
38 else if ((new_dx = ex - ey) < intDsize*LF_minlen)
39 new_dx = intDsize*LF_minlen;
40 var uintL len = ceiling(new_dx,intDsize);
41 if (intDsize*len < dx)
42 return shorten(x,len);