blob: 8ec97e17c9f7f7bb9c31b571e8e55445e7312c19 (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#if 0
# define TGSOURCE "log.c"
#include <errno.h>
#include <math.h>
#include "_tgmath.h"
/** natural logarithm **/
TYPE TGFN(log)(TYPE x)
{
switch (fpclassify(x)) {
case FP_ZERO: feraiseexcept(FE_DIVBYZERO); return - INFINITY;
case FP_INFINITE: if (!signbit(x)) { return x; }
default: break;
}
if (x == 1.0) {
return 0.0;
}
if (x < 0) {
feraiseexcept(FE_INVALID);
return NAN;
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)
*/
#endif
|