aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2025-04-09 18:24:11 +0200
committerJakub Jelinek <jakub@redhat.com>2025-04-09 18:24:11 +0200
commit63c99cd50bc9c10f0692f7cb31f4c5f02ff526df (patch)
tree814264c88a645a8287934a717022cb729a181194
parent12a497c716f0a06be5946cabb8c3ec22a079771e (diff)
downloadglibc-63c99cd50bc9c10f0692f7cb31f4c5f02ff526df.zip
glibc-63c99cd50bc9c10f0692f7cb31f4c5f02ff526df.tar.gz
glibc-63c99cd50bc9c10f0692f7cb31f4c5f02ff526df.tar.bz2
math: Fix up THREEp96 constant in expf128 [BZ #32411]
As mentioned by the reporter in a pull request against gcc-mirror, the THREEp96 constant in e_expl.c is incorrect, it is actually 0x3.p+94f128 rather than 0x3.p+96f128. The algorithm uses that to compute the t2 integer (tval2), by whose delta it adjusts the x+xl pair and then in the result uses the precomputed exp value for that entry. Using 0x3.p+94f128 rather than 0x3.p+96f128 results in tval2 sometimes being one smaller, sometimes one larger than the desired value, thus can mean the x+xl pair after adjustment will be larger in absolute value than it should be. DesWursters created a test program for this https://github.com/DesWurstes/comparefloats and his results were total: 1135000000 not_equal: 4322 earlier_score: 674 later_score: 3648 I've modified this so with https://sourceware.org/bugzilla/show_bug.cgi?id=32411#c3 so that it actually tests pseudo-random _Float128 values with range (-16384.,16384) with strong bias on values larger than 0.0002 in absolute value (so that tval1/tval2 aren't zero most of the time) and that gave total: 10000000000 not_equal: 29861 earlier_score: 4606 later_score: 25255 So, in both cases, in most cases the change doesn't result in any differences, and in those rare cases where does, about 85% have smaller ulp than without the patch. Additionally I've tried https://sourceware.org/bugzilla/show_bug.cgi?id=32411#c4 and in 2 billion iterations it didn't find any case where x+xl after the adjustments without this change would be smaller in absolute value compared to x+xl after the adjustments with this change. Reviewed-by: Joseph Myers <josmyers@redhat.com>
-rw-r--r--sysdeps/ieee754/ldbl-128/e_expl.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sysdeps/ieee754/ldbl-128/e_expl.c b/sysdeps/ieee754/ldbl-128/e_expl.c
index 25b45c7..4855c6b 100644
--- a/sysdeps/ieee754/ldbl-128/e_expl.c
+++ b/sysdeps/ieee754/ldbl-128/e_expl.c
@@ -79,7 +79,7 @@ L(-11433.4627433362978788372438434526231),
/* 3x2^96 */
#define THREEp96 C[2]
- L(59421121885698253195157962752.0),
+ L(237684487542793012780631851008.0),
/* 3x2^103 */
#define THREEp103 C[3]