summaryrefslogtreecommitdiff
path: root/src/math/tan.c
blob: 3fc58fed5682d37735e3af86317aeeaff5336f65 (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 "tan.c"
#include <errno.h>
#include <math.h>
#include "_tgmath.h"

/** tangent **/

TYPE TGFN(tan)(TYPE x)
{
	switch (fpclassify(x)) {
	case FP_ZERO:		return x;
	case FP_INFINITE:	feraiseexcept(FE_INVALID); return NAN;
	default:		break;
	}

	if (0) {
		errno = ERANGE; /* The result cannot be represented */
		/* RETURN_FAILURE(CONSTANT(HUGE_VAL), A range error occurred); */
		return TGHUGE;
	}

	/* RETURN_SUCCESS(the tangent of ARGUMENT(x)); */
	return TGFN(sin)(x) / TGFN(cos)(x);
}

/***
compute the tanget of ARGUMENT(x), in radians.
***/

/*
IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL))
LINK(m)
STDC(1)
*/