glibc/sysdeps/ieee754
Jakub Jelinek 63c99cd50b 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>
2025-04-09 18:24:11 +02:00
..
dbl-64 stdio-common: Reject real data w/o exponent digits in scanf [BZ #12701] 2025-03-28 12:35:53 +00:00
float128 Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
flt-32 stdio-common: Reject real data w/o exponent digits in scanf [BZ #12701] 2025-03-28 12:35:53 +00:00
ldbl-64-128 stdio-common: Add scanf long double data for IEEE 754 binary64 format 2025-03-25 09:40:20 +00:00
ldbl-96 stdio-common: Reject real data w/o exponent digits in scanf [BZ #12701] 2025-03-28 12:35:53 +00:00
ldbl-128 math: Fix up THREEp96 constant in expf128 [BZ #32411] 2025-04-09 18:24:11 +02:00
ldbl-128ibm stdio-common: Reject real data w/o exponent digits in scanf [BZ #12701] 2025-03-28 12:35:53 +00:00
ldbl-128ibm-compat Implement C23 pown 2025-03-27 10:44:44 +00:00
ldbl-opt stdio-common: Reject real data w/o exponent digits in scanf [BZ #12701] 2025-03-28 12:35:53 +00:00
soft-fp Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
Makefile
ieee754.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
k_standard.c Use copysign functions not __copysign functions in glibc libm. 2018-09-27 20:04:48 +00:00
k_standardf.c Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
k_standardl.c Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
libm-alias-finite.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
s_lib_version.c
s_matherr.c
s_signgam.c Remove unnecessary math_private.h includes. 2018-09-28 21:53:33 +00:00