projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
math.h: make __FLOAT_BITS and __DOUBLE_BITS C89
[musl]
/
src
/
math
/
fma.c
diff --git
a/src/math/fma.c
b/src/math/fma.c
index
84868be
..
02f5c86
100644
(file)
--- a/
src/math/fma.c
+++ b/
src/math/fma.c
@@
-431,12
+431,24
@@
double fma(double x, double y, double z)
/*
* There is no need to worry about double rounding in directed
* rounding modes.
/*
* There is no need to worry about double rounding in directed
* rounding modes.
- *
TODO: underflow is not
raised properly, example in downward rounding:
+ *
But underflow may not be
raised properly, example in downward rounding:
* fma(0x1.000000001p-1000, 0x1.000000001p-30, -0x1p-1066)
*/
* fma(0x1.000000001p-1000, 0x1.000000001p-30, -0x1p-1066)
*/
+ double ret;
+#if defined(FE_INEXACT) && defined(FE_UNDERFLOW)
+ int e = fetestexcept(FE_INEXACT);
+ feclearexcept(FE_INEXACT);
+#endif
fesetround(oround);
adj = r.lo + xy.lo;
fesetround(oround);
adj = r.lo + xy.lo;
- return scalbn(r.hi + adj, spread);
+ ret = scalbn(r.hi + adj, spread);
+#if defined(FE_INEXACT) && defined(FE_UNDERFLOW)
+ if (ilogb(ret) < -1022 && fetestexcept(FE_INEXACT))
+ feraiseexcept(FE_UNDERFLOW);
+ else if (e)
+ feraiseexcept(FE_INEXACT);
+#endif
+ return ret;
}
adj = add_adjusted(r.lo, xy.lo);
}
adj = add_adjusted(r.lo, xy.lo);