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/log10.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/math/log10.c (limited to 'src/math/log10.c') diff --git a/src/math/log10.c b/src/math/log10.c new file mode 100644 index 00000000..5000910b --- /dev/null +++ b/src/math/log10.c @@ -0,0 +1,34 @@ +# define TGSOURCE "log10.c" +#include +#include "nonstd/tgmath.h" +#include "errno.h" + +/** base-10 logarithm **/ +TYPE TGFN(log10)(TYPE x) +{ + if (x < 0) { + errno = EDOM; /* ARGUMENT(x) is negative */ + return TGHUGE; + } + + if (x == 0) { + errno = ERANGE; /* ARGUMENT(x) is LITERAL(0) */ + /* RETURN_FAILURE(CONSTANT(HUGE_VAL), A range error occurred); */ + return TGHUGE; + } + + /* RETURN_SUCCESS(the base-10 logarithm of ARGUMENT(x)); */ + return x; +} + +/*** +compute the base-ten logarithm of ARGUMENT(x). +***/ + +/* +IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) +LINK(m) +*/ +/* +STDC(1) +*/ -- cgit v1.2.1