Skip to content

Commit 67f82ca

Browse files
committed
Use Dekker (5.12) directly. Avoids calling dl_add() and saves a comparison.
1 parent d274325 commit 67f82ca

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

Modules/mathmodule.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2865,15 +2865,6 @@ dl_zero()
28652865
{
28662866
return (DoubleLength) {0.0, 0.0};
28672867
}
2868-
2869-
static inline DoubleLength
2870-
dl_split(double x) {
2871-
double t = x * 134217729.0; /* Veltkamp constant = float(0x8000001) */
2872-
double hi = t - (t - x);
2873-
double lo = x - hi;
2874-
return (DoubleLength) {hi, lo};
2875-
}
2876-
28772868
static inline DoubleLength
28782869
dl_add(DoubleLength total, double x)
28792870
{
@@ -2888,12 +2879,24 @@ dl_add(DoubleLength total, double x)
28882879
}
28892880

28902881
static inline DoubleLength
2891-
dl_mul(double p, double q)
2882+
dl_split(double x) {
2883+
double t = x * 134217729.0; /* Veltkamp constant = float(0x8000001) */
2884+
double hi = t - (t - x);
2885+
double lo = x - hi;
2886+
return (DoubleLength) {hi, lo};
2887+
}
2888+
2889+
static inline DoubleLength
2890+
dl_mul(double x, double y)
28922891
{
2893-
DoubleLength pp = dl_split(p);
2894-
DoubleLength qq = dl_split(q);
2895-
DoubleLength product = {pp.hi * qq.hi, pp.lo * qq.lo};
2896-
return dl_add(product, pp.hi * qq.lo + pp.lo * qq.hi);
2892+
/* Dekker mul12(). Section (5.12) */
2893+
DoubleLength xx = dl_split(x);
2894+
DoubleLength yy = dl_split(y);
2895+
double p = xx.hi * yy.hi;
2896+
double q = xx.hi * yy.lo + xx.lo * yy.hi;
2897+
double z = p + q;
2898+
double zz = p - z + q + xx.lo * yy.lo;
2899+
return (DoubleLength) {z, zz};
28972900
}
28982901

28992902
static inline DoubleLength

0 commit comments

Comments
 (0)