1 // cl_LF_shortenwith().
12 #include "cln/abort.h"
15 #define MAYBE_INLINE2 inline
16 #include "cl_LF_precision.cc"
18 #define MAYBE_INLINE inline
19 #include "cl_LF_exponent.cc"
23 const cl_LF cl_LF_shortenwith (const cl_LF& x, const cl_LF& y)
26 // x = 0.0 -> Precision egal, return x.
27 // ex := float_exponent(x), dx := float_digits(x), 1 ulp(x) = 2^(ex-dx).
28 // ey := float_exponent(y).
29 // Falls ex-dx < ey, x von Precision dx auf ex-ey verkürzen.
30 var sintL ey = float_exponent(y);
31 var sintL ex = float_exponent(x);
32 var uintL dx = float_precision(x);
33 if (dx==0) // zerop(x) ?
35 var sintL ulpx = ex - dx;
36 if ((ex<0 && ulpx>=0) // underflow?
38 ) { // Now ex-dx < ey, hence ex-ey < dx.
41 new_dx = intDsize*LF_minlen;
42 else if ((new_dx = ex - ey) < intDsize*LF_minlen)
43 new_dx = intDsize*LF_minlen;
44 var uintL len = ceiling(new_dx,intDsize);
45 if (intDsize*len < dx)
46 return shorten(x,len);