summaryrefslogtreecommitdiff
path: root/libm/s_ldexp.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-01-03 14:42:54 (GMT)
committerDenis Vlasenko <vda.linux@googlemail.com>2009-01-03 14:42:54 (GMT)
commiteb51bac1b3f43c4fcccdf8206afb8a070fecaa07 (patch)
tree5253e96ffffa5ee3d72ccbd92f47fbf7d16d2264 /libm/s_ldexp.c
parent33836c9854b39638a8460bdf5e7d761bb5d1e6ae (diff)
libm/e_scalb.c: remove unused #ifdef _SCALB_INT branches
libm/s_ldexp.c: add TODO
Diffstat (limited to 'libm/s_ldexp.c')
-rw-r--r--libm/s_ldexp.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/libm/s_ldexp.c b/libm/s_ldexp.c
index 1b681cb..b2809af 100644
--- a/libm/s_ldexp.c
+++ b/libm/s_ldexp.c
@@ -13,11 +13,27 @@
#include "math_private.h"
#include <errno.h>
+/* TODO: POSIX says:
+ *
+ * "If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
+ * then errno shall be set to [ERANGE]. If the integer expression
+ * (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow
+ * floating-point exception shall be raised."
+ *
+ * *And it says the same about scalbn*! Thus these two functions
+ * are the same and can be just aliased.
+ *
+ * Currently, ldexp tries to be vaguely POSIX compliant while scalbn
+ * does not (it does not set ERRNO).
+ */
+
double ldexp(double value, int exp)
{
- if(!isfinite(value)||value==0.0) return value;
- value = scalbn(value,exp);
- if(!isfinite(value)||value==0.0) errno = ERANGE;
+ if (!isfinite(value) || value == 0.0)
+ return value;
+ value = scalbn(value, exp);
+ if (!isfinite(value) || value == 0.0)
+ errno = ERANGE;
return value;
}
libm_hidden_def(ldexp)