From 7ef8a7379f7f7d09e71ccae2a0b688c3cd80423f Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Fri, 8 Feb 2019 18:42:39 -0500 Subject: merge sources into single tree --- src/math/ldexp.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/math/ldexp.c (limited to 'src/math/ldexp.c') diff --git a/src/math/ldexp.c b/src/math/ldexp.c new file mode 100644 index 00000000..f32c1d76 --- /dev/null +++ b/src/math/ldexp.c @@ -0,0 +1,30 @@ +# define TGSOURCE "ldexp.c" +#include +#include "nonstd/tgmath.h" +#include "errno.h" + +/** multiply by a power of 2 **/ +TYPE TGFN(ldexp)(TYPE x, int exp) +{ + if (0) { + errno = ERANGE; /* The result cannot be represented */ + /* RETURN_FAILURE(CONSTANT(HUGE_VAL), A range error occurred); */ + return TGHUGE; + } + + /* RETURN_SUCCESS(ARGUMENT(x) * POW(2,ARGUMENT(exp))); */ + return x * TGFN(pow)(2, exp); +} + +/*** +multiply the floating-point number specifed by ARGUMENT(x) +by 2 raised to the power ARGUMENT(exp). +***/ + +/* +IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) +LINK(m) +*/ +/* +STDC(1) +*/ -- cgit v1.2.1