summaryrefslogtreecommitdiff
path: root/src/math/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/math/log.c')
-rw-r--r--src/math/log.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/math/log.c b/src/math/log.c
new file mode 100644
index 00000000..a75fdafa
--- /dev/null
+++ b/src/math/log.c
@@ -0,0 +1,34 @@
+# define TGSOURCE "log.c"
+#include <math.h>
+#include "nonstd/tgmath.h"
+#include "errno.h"
+
+/** natural logarithm **/
+TYPE TGFN(log)(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 natural logarithm of ARGUMENT(x)); */
+ return x;
+}
+
+/***
+compute the natural logarithm of ARGUMENT(x).
+***/
+
+/*
+IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL))
+LINK(m)
+*/
+/*
+STDC(1)
+*/