12 #include "cl_F_tran.h"
15 #include "cl_lfloat.h"
19 #define MAYBE_INLINE inline
20 #include "cl_LF_minusp.cc"
21 #include "cl_LF_exponent.cc"
23 // Division durch ln(2).
24 inline const cl_F_div_t cl_floor_ln2 (const cl_F& x)
26 // Bei 0<=x<1/2 kann man sofort q:=0 setzen.
27 if (!minusp(x) && (float_exponent(x) < 0))
28 return cl_F_div_t(0,x);
30 return floor2(x,cl_ln2(x));
32 inline const cl_LF_div_t cl_floor_ln2 (const cl_LF& x)
34 // Bei 0<=x<1/2 kann man sofort q:=0 setzen.
35 if (!minusp(x) && (float_exponent(x) < 0))
36 return cl_LF_div_t(0,x);
38 return floor2(x,The(cl_LF)(cl_ln2(x)));
41 const cl_F exp (const cl_F& x)
44 // d := (float-digits x),
45 // Genauigkeit um sqrt(d)+max(integer-length(e)) Bits erhöhen,
46 // (q,r) := (floor x ln(2))
47 // Ergebnis ist exp(q*ln(2)+r) = (scale-float exp(r) q).
49 // Rechengenauigkeit erhöhen und durch ln(2) dividieren:
50 if (longfloatp(x) && (TheLfloat(x)->len >= 84)) {
52 var cl_LF_div_t q_r = cl_floor_ln2(extend(x,TheLfloat(x)->len+1));
53 var cl_I& q = q_r.quotient;
54 var cl_LF& r = q_r.remainder;
55 return cl_float(scale_float(expx_ratseries(r),q),x);
57 var cl_F_div_t q_r = cl_floor_ln2(cl_F_extendsqrtx(x));
58 var cl_I& q = q_r.quotient;
59 var cl_F& r = q_r.remainder;
60 return cl_float(scale_float(expx_naive(r),q),x);