1 // cl_F_shortenrelative().
13 #include "cln/abort.h"
17 const cl_F cl_F_shortenrelative (const cl_F& x, const cl_F& y)
20 // x = 0.0 -> Precision egal, return x.
21 // ex := float_exponent(x), ey := float_exponent(y).
22 // dx := float_digits(x), dy := float_digits(y).
23 // 1 ulp(x) = 2^(ex-dx), 1 ulp(y) = 2^(ey-dy).
24 // Falls ex-dx < ey-dy, x von Precision dx auf dy-ey+ex verkürzen.
25 var sintL ey = float_exponent(y);
26 var sintC dy = float_precision(y);
27 if (dy==0) // zerop(y) ?
29 var sintL ex = float_exponent(x);
30 var sintC dx = float_precision(x);
31 if (dx==0) // zerop(x) ?
33 var sintL d = ex - ey;
34 if (ex>=0 && ey<0 && d<0) // d overflow?
36 if (ex<0 && ey>=0 && d>=0) // d underflow?
40 var uintC new_dx = dy + d;
41 floatformatcase(new_dx
42 , return cl_F_to_SF(x);
43 , return cl_F_to_FF(x);
44 , return cl_F_to_DF(x);
45 , if (intDsize*len < (uintC)dx)
46 return shorten(The(cl_LF)(x),len);