glibc/sysdeps/ieee754/ldbl-128ibm
Alan Modra 4cf69995e2 Fix for [BZ #15680] IBM long double inaccuracy
http://sourceware.org/ml/libc-alpha/2013-06/msg00919.html

I discovered a number of places where denormals and other corner cases
were being handled wrongly.

- printf_fphex.c: Testing for the low double exponent being zero is
unnecessary.  If the difference in exponents is less than 53 then the
high double exponent must be nearing the low end of its range, and the
low double exponent hit rock bottom.

- ldbl2mpn.c: A denormal (ie. exponent of zero) value is treated as
if the exponent was one, so shift mantissa left by one.  Code handling
normalisation of the low double mantissa lacked a test for shift count
greater than bits in type being shifted, and lacked anything to handle
the case where the difference in exponents is less than 53 as in
printf_fphex.c.

- math_ldbl.h (ldbl_extract_mantissa): Same as above, but worse, with
code testing for exponent > 1 for some reason, probably a typo for >= 1.

- math_ldbl.h (ldbl_insert_mantissa): Round the high double as per
mpn2ldbl.c (hi is odd or explicit mantissas non-zero) so that the
number we return won't change when applying ldbl_canonicalize().
Add missing overflow checks and normalisation of high mantissa.
Correct misleading comment: "The hidden bit of the lo mantissa is
zero" is not always true as can be seen from the code rounding the hi
mantissa.  Also by inspection, lzcount can never be less than zero so
remove that test.  Lastly, masking bitfields to their widths can be
left to the compiler.

- mpn2ldbl.c: The overflow checks here on rounding of high double were
just plain wrong.  Incrementing the exponent must be accompanied by a
shift right of the mantissa to keep the value unchanged.  Above notes
for ldbl_insert_mantissa are also relevant.

	[BZ #15680]
	* sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c: Comment fix.
	* sysdeps/ieee754/ldbl-128ibm/printf_fphex.c
	(PRINT_FPHEX_LONG_DOUBLE): Tidy code by moving -53 into ediff
	calculation.  Remove unnecessary test for denormal exponent.
	* sysdeps/ieee754/ldbl-128ibm/ldbl2mpn.c (__mpn_extract_long_double):
	Correct handling of denormals.  Avoid undefined shift behaviour.
	Correct normalisation of low mantissa when low double is denormal.
	* sysdeps/ieee754/ldbl-128ibm/math_ldbl.h
	(ldbl_extract_mantissa): Likewise.  Comment.  Use uint64_t* for hi64.
	(ldbl_insert_mantissa): Make both hi64 and lo64 parms uint64_t.
	Correct normalisation of low mantissa.  Test for overflow of high
	mantissa and normalise.
	(ldbl_nearbyint): Use more readable constant for two52.
	* sysdeps/ieee754/ldbl-128ibm/mpn2ldbl.c
	(__mpn_construct_long_double): Fix test for overflow of high
	mantissa and correct normalisation.  Avoid undefined shift.
2013-10-04 10:30:56 +09:30
..
e_acoshl.c BZ #15055: Use __ieee754_sqrl in acoshl for lbdl-128ibm 2013-03-04 11:37:51 -03:00
e_acosl.c Fix for ldbl-128ibm acosl/asinl inaccuracies 2012-05-04 13:06:32 +02:00
e_asinl.c Fix for ldbl-128ibm acosl/asinl inaccuracies 2012-05-04 13:06:32 +02:00
e_atan2l.c Fix ldbl-128ibm atan2l for x near 1. 2012-10-31 20:44:59 +00:00
e_atanhl.c Fix ldbl-128ibm "set but not used" warnings. 2012-12-04 21:19:17 +00:00
e_coshl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
e_exp10l.c IBM long double mechanical changes to support little-endian 2013-10-04 10:28:42 +09:30
e_expl.c IBM long double mechanical changes to support little-endian 2013-10-04 10:28:42 +09:30
e_fmodl.c Fix for wrong ldbl128-ibm fmodl commit 2012-06-05 21:33:23 -03:00
e_gammal_r.c Improve tgamma accuracy (bugs 2546, 2560, 5159, 15426). 2013-05-08 11:58:18 +00:00
e_hypotl.c Fix ldbl-128ibm hypotl internal underflows (bug 14869). 2012-11-22 14:58:41 +00:00
e_ilogbl.c Fix ilogb exception and errno (bug 6794) 2012-04-17 22:12:53 +02:00
e_j0l.c
e_j1l.c
e_jnl.c Set up errno properly for yn. 2012-07-25 12:59:36 +02:00
e_lgammal_r.c
e_log2l.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
e_log10l.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
e_logl.c Fix e_logl (128ibm) spurious underflow 2013-03-28 09:52:48 -03:00
e_powl.c Fix powl inaccuracy for ldbl-128ibm (bug 14914). 2012-12-04 14:39:24 +00:00
e_rem_pio2l.c Fix for [BZ #15680] IBM long double inaccuracy 2013-10-04 10:30:56 +09:30
e_remainderl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
e_sinhl.c Fix ctan, ctanh overflow for ldbl-128ibm (bug 11521). 2012-04-26 11:18:11 -05:00
e_sqrtl.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
gamma_productl.c Improve tgamma accuracy (bugs 2546, 2560, 5159, 15426). 2013-05-08 11:58:18 +00:00
ieee754.h IBM long double mechanical changes to support little-endian 2013-10-04 10:28:42 +09:30
k_cosl.c Remove trailing whitespace. 2013-06-05 20:44:03 +00:00
k_sincosl.c Remove trailing whitespace. 2013-06-05 20:44:03 +00:00
k_sinl.c Remove trailing whitespace. 2013-06-05 20:44:03 +00:00
k_tanl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
ldbl2mpn.c Fix for [BZ #15680] IBM long double inaccuracy 2013-10-04 10:30:56 +09:30
Makefile
math_ldbl.h Fix for [BZ #15680] IBM long double inaccuracy 2013-10-04 10:30:56 +09:30
mpn2ldbl.c Fix for [BZ #15680] IBM long double inaccuracy 2013-10-04 10:30:56 +09:30
printf_fphex.c Fix for [BZ #15680] IBM long double inaccuracy 2013-10-04 10:30:56 +09:30
s_asinhl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_atanl.c Fix ldbl-128ibm atanl spurious underflows (bug 14871). 2012-11-22 19:56:47 +00:00
s_cbrtl.c
s_ceill.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
s_copysignl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_cosl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_cprojl.c Fix cproj handling of (finite, NaN) arguments (bug 15531). 2013-08-20 19:41:15 +00:00
s_ctanhl.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
s_ctanl.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
s_erfl.c Fix spurious undeflow for ldbl-128ibm erfl 2012-06-05 10:42:49 -03:00
s_expm1l.c Fix expm1l spurious underflows for ldbl-128ibm. 2012-11-22 14:55:17 +00:00
s_fabsl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_finitel.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_floorl.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
s_fmal.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
s_fpclassifyl.c Fix leading whitespaces. 2013-06-06 20:36:07 +02:00
s_frexpl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_isinf_nsl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_isinfl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_isnanl.c Fix ldbl-128ibm "set but not used" warnings. 2012-12-04 21:19:17 +00:00
s_issignalingl.c New <math.h> macro named issignaling to check for a signaling NaN (sNaN). 2013-04-02 13:51:02 +02:00
s_llrintl.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
s_llroundl.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
s_log1pl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_logbl.c Fix ldbl-128ibm "set but not used" warnings. 2012-12-04 21:19:17 +00:00
s_lrintl.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
s_lroundl.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
s_modfl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_nearbyintl.c IBM long double mechanical changes to support little-endian 2013-10-04 10:28:42 +09:30
s_nextafterl.c Remove trailing whitespace. 2013-06-05 20:44:03 +00:00
s_nexttoward.c Fix leading whitespaces. 2013-06-06 20:36:07 +02:00
s_nexttowardf.c Fix nexttoward bugs (bugs 2550, 2570). 2012-05-01 15:37:43 +00:00
s_remquol.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
s_rintl.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
s_roundl.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
s_scalblnl.c Fix leading whitespaces. 2013-06-06 20:36:07 +02:00
s_scalbnl.c Fix leading whitespaces. 2013-06-06 20:36:07 +02:00
s_signbitl.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
s_sincosl.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
s_sinl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_tanhl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_tanl.c Use <> for math.h and math_private.h everywhere. 2012-03-09 16:09:10 -08:00
s_truncl.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
strtold_l.c IBM long double mechanical changes to support little-endian 2013-10-04 10:28:42 +09:30
t_sincosl.c Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
w_expl.c BZ#13889: expl (709.75) wrongly overflows for ldbl-128ibm 2013-03-22 12:39:10 -03:00
x2y2m1l.c IBM long double mechanical changes to support little-endian 2013-10-04 10:28:42 +09:30