From 06696f40afe58a231e2531c8bf6d9f0dadb92e51 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Sun, 3 Mar 2019 21:25:50 -0500 Subject: outline details from C18 annex F --- src/math/ldexp.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/math/ldexp.c') 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); */ -- cgit v1.2.1