Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Donnelly <mingw.android@gmail.com>2016-04-06 04:59:53 +0300
committerCorinna Vinschen <corinna@vinschen.de>2016-08-22 15:17:58 +0300
commit96fc528397f02a8ac36cfd66179fed815d3ab527 (patch)
treef6ababe91cdc0bd8c440a5e06fa777f7ab35c87b
parent5085ce21063a9edaff9856b0caf3a76adcbf68e8 (diff)
sqrt: Fix NaN propagation for IEEE Std 754-2008
The R language has some hacks specifically for mingw-w64 that were caused by our handling of NaNs in sqrt(x). R uses a special valued NaN to mean 'Not Available' and expects it to be retained through various calculations. Our sqrt(x) doesn't do this, instead it normalises such a NaN (retaining sign). From: http://wwwf.imperial.ac.uk/~drmii/M3SC_2016/IEEE_2008_4610935.pdf "6.2.3 NaN propagation An operation that propagates a NaN operand to its result and has a single NaN as an input should produce a NaN with the payload of the input NaN if representable in the destination format." There might even be a slight speed-up from this too. Thanks to Duncan Murdoch for finding the reference.
-rw-r--r--winsup/cygwin/math/sqrt.def.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/winsup/cygwin/math/sqrt.def.h b/winsup/cygwin/math/sqrt.def.h
index 1048130d0..2690d1d9f 100644
--- a/winsup/cygwin/math/sqrt.def.h
+++ b/winsup/cygwin/math/sqrt.def.h
@@ -73,9 +73,8 @@ __FLT_ABI (sqrt) (__FLT_TYPE x)
if (x_class == FP_ZERO)
return __FLT_CST (-0.0);
- res = (signbit (x) ? -__FLT_NAN : __FLT_NAN);
- __FLT_RPT_DOMAIN ("sqrt", x, 0.0, res);
- return res;
+ __FLT_RPT_DOMAIN ("sqrt", x, 0.0, x);
+ return x;
}
else if (x_class == FP_ZERO)
return __FLT_CST (0.0);