summaryrefslogtreecommitdiff
path: root/src/math/log.c
blob: a75fdafa90129b10a459512026ea220431b8bb3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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)
*/