1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-04 09:09:56 +00:00

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.)
This commit is contained in:
Bruce Evans 2008-03-30 17:28:27 +00:00
parent f94997c8d7
commit c0c7ddd3a8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=177749
2 changed files with 2 additions and 2 deletions

View File

@ -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);

View File

@ -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;