summaryrefslogtreecommitdiff
path: root/src/math/ldexp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/ldexp.c')
-rw-r--r--src/math/ldexp.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/math/ldexp.c b/src/math/ldexp.c
index ab143982..33e2f381 100644
--- a/src/math/ldexp.c
+++ b/src/math/ldexp.c
@@ -6,6 +6,16 @@
/** multiply by a power of 2 **/
TYPE TGFN(ldexp)(TYPE x, int exp)
{
+ switch (fpclassify(x)) {
+ case FP_ZERO: return x;
+ case FP_INFINITE: return x;
+ default: break;
+ }
+
+ if (exp == 0) {
+ return x;
+ }
+
if (0) {
errno = ERANGE; /* The result cannot be represented */
/* RETURN_FAILURE(CONSTANT(HUGE_VAL), A range error occurred); */