summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2008-03-30 17:28:27 +0000
committerbde <bde@FreeBSD.org>2008-03-30 17:28:27 +0000
commitb06e3a074e790b19403a03d0155466a343805194 (patch)
tree4b7b91dd6ca950f37e8ffa401e71abf879182368 /lib
parent95436ce20dab5a34ba46373410b96411b1734578 (diff)
downloadFreeBSD-src-b06e3a074e790b19403a03d0155466a343805194.zip
FreeBSD-src-b06e3a074e790b19403a03d0155466a343805194.tar.gz
Use the expression fabs(x+0.0)-fabs(y+0.0) instead of
fabs(x+0.0)+fabs(y+0.0) when mixing NaNs. This improves consistency of the result by making it harder for the compiler to reorder the operands. (FP addition is not necessarily commutative because the order of operands makes a difference on some machines iff the operands are both NaNs.)
Diffstat (limited to 'lib')
-rw-r--r--lib/msun/src/e_hypot.c2
-rw-r--r--lib/msun/src/e_hypotf.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/msun/src/e_hypot.c b/lib/msun/src/e_hypot.c
index 932b5db..8f1cd10 100644
--- a/lib/msun/src/e_hypot.c
+++ b/lib/msun/src/e_hypot.c
@@ -68,7 +68,7 @@ __ieee754_hypot(double x, double y)
if(ha >= 0x7ff00000) { /* Inf or NaN */
u_int32_t low;
/* Use original arg order iff result is NaN; quieten sNaNs. */
- w = fabs(x+0.0)+fabs(y+0.0);
+ w = fabs(x+0.0)-fabs(y+0.0);
GET_LOW_WORD(low,a);
if(((ha&0xfffff)|low)==0) w = a;
GET_LOW_WORD(low,b);
diff --git a/lib/msun/src/e_hypotf.c b/lib/msun/src/e_hypotf.c
index b760cc6..c70668e 100644
--- a/lib/msun/src/e_hypotf.c
+++ b/lib/msun/src/e_hypotf.c
@@ -37,7 +37,7 @@ __ieee754_hypotf(float x, float y)
if(ha > 0x58800000) { /* a>2**50 */
if(ha >= 0x7f800000) { /* Inf or NaN */
/* Use original arg order iff result is NaN; quieten sNaNs. */
- w = fabsf(x+0.0F)+fabsf(y+0.0F);
+ w = fabsf(x+0.0F)-fabsf(y+0.0F);
if(ha == 0x7f800000) w = a;
if(hb == 0x7f800000) w = b;
return w;
OpenPOWER on IntegriCloud