mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-09 09:40:42 +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:
parent
f94997c8d7
commit
c0c7ddd3a8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=177749
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user