1TAN(P) POSIX Programmer's Manual TAN(P)
2
3
4
6 tan, tanf, tanl - tangent function
7
9 #include <math.h>
10
11 double tan(double x);
12 float tanf(float x);
13 long double tanl(long double x);
14
15
17 These functions shall compute the tangent of their argument x, measured
18 in radians.
19
20 An application wishing to check for error situations should set errno
21 to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these
22 functions. On return, if errno is non-zero or fetestexcept(FE_INVALID
23 | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has
24 occurred.
25
27 Upon successful completion, these functions shall return the tangent of
28 x.
29
30 If the correct value would cause underflow, and is not representable, a
31 range error may occur, and either 0.0 (if supported), or an imple‐
32 mentation-defined value shall be returned.
33
34 If x is NaN, a NaN shall be returned.
35
36 If x is ±0, x shall be returned.
37
38 If x is subnormal, a range error may occur and x should be returned.
39
40 If x is ±Inf, a domain error shall occur, and either a NaN (if sup‐
41 ported), or an implementation-defined value shall be returned.
42
43 If the correct value would cause underflow, and is representable, a
44 range error may occur and the correct value shall be returned.
45
46 If the correct value would cause overflow, a range error shall occur
47 and tan(), tanf(), and tanl() shall return ±HUGE_VAL, ±HUGE_VALF, and
48 ±HUGE_VALL, respectively, with the same sign as the correct value of
49 the function.
50
52 These functions shall fail if:
53
54 Domain Error
55 The value of x is ±Inf.
56
57 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
58 then errno shall be set to [EDOM]. If the integer expression
59 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the invalid
60 floating-point exception shall be raised.
61
62 Range Error
63 The result overflows
64
65 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
66 then errno shall be set to [ERANGE]. If the integer expression
67 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the overflow
68 floating-point exception shall be raised.
69
70
71 These functions may fail if:
72
73 Range Error
74 The result underflows, or the value of x is subnormal.
75
76 If the integer expression (math_errhandling & MATH_ERRNO) is non-zero,
77 then errno shall be set to [ERANGE]. If the integer expression
78 (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow
79 floating-point exception shall be raised.
80
81
82 The following sections are informative.
83
85 Taking the Tangent of a 45-Degree Angle
86 #include <math.h>
87 ...
88 double radians = 45.0 * M_PI / 180;
89 double result;
90 ...
91 result = tan (radians);
92
94 There are no known floating-point representations such that for a nor‐
95 mal argument, tan( x) is either overflow or underflow.
96
97 These functions may lose accuracy when their argument is near a multi‐
98 ple of pi/2 or is far from 0.0.
99
100 On error, the expressions (math_errhandling & MATH_ERRNO) and
101 (math_errhandling & MATH_ERREXCEPT) are independent of each other, but
102 at least one of them must be non-zero.
103
105 None.
106
108 None.
109
111 atan() , feclearexcept() , fetestexcept() , isnan() , the Base Defini‐
112 tions volume of IEEE Std 1003.1-2001, Section 4.18, Treatment of Error
113 Conditions for Mathematical Functions, <math.h>
114
116 Portions of this text are reprinted and reproduced in electronic form
117 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
118 -- Portable Operating System Interface (POSIX), The Open Group Base
119 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
120 Electrical and Electronics Engineers, Inc and The Open Group. In the
121 event of any discrepancy between this version and the original IEEE and
122 The Open Group Standard, the original IEEE and The Open Group Standard
123 is the referee document. The original Standard can be obtained online
124 at http://www.opengroup.org/unix/online.html .
125
126
127
128IEEE/The Open Group 2003 TAN(P)