summaryrefslogtreecommitdiff
path: root/src/math/log10.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/log10.c')
-rw-r--r--src/math/log10.c34
1 files changed, 34 insertions, 0 deletions
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 <math.h>
+#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)
+*/