mirror of
git://git.musl-libc.org/musl
synced 2025-01-10 16:49:50 +00:00
math: fix fmaf not to depend on FE_TOWARDZERO
This commit is contained in:
parent
937822abb6
commit
4f3d346bff
@ -77,17 +77,16 @@ float fmaf(float x, float y, float z)
|
|||||||
* If result is inexact, and exactly halfway between two float values,
|
* If result is inexact, and exactly halfway between two float values,
|
||||||
* we need to adjust the low-order bit in the direction of the error.
|
* we need to adjust the low-order bit in the direction of the error.
|
||||||
*/
|
*/
|
||||||
#ifdef FE_TOWARDZERO
|
double err;
|
||||||
fesetround(FE_TOWARDZERO);
|
int neg = u.i >> 63;
|
||||||
#endif
|
if (neg == (z > xy))
|
||||||
volatile double vxy = xy; /* XXX work around gcc CSE bug */
|
err = xy - result + z;
|
||||||
double adjusted_result = vxy + z;
|
else
|
||||||
fesetround(FE_TONEAREST);
|
err = z - result + xy;
|
||||||
if (result == adjusted_result) {
|
if (neg == (err < 0))
|
||||||
u.f = adjusted_result;
|
|
||||||
u.i++;
|
u.i++;
|
||||||
adjusted_result = u.f;
|
else
|
||||||
}
|
u.i--;
|
||||||
z = adjusted_result;
|
z = u.f;
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user