summaryrefslogtreecommitdiff
path: root/devdocs/c/numeric%2Fmath%2Fatan.html
blob: 4ba682e3f1128712e4f4da372e504f090a0b2ef1 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
    <h1 id="firstHeading" class="firstHeading">atan, atanf, atanl</h1>            <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;math.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">float       atanf( float arg );</pre>
</td> <td> (1) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl"> <td> <pre data-language="c">double      atan( double arg );</pre>
</td> <td> (2) </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">long double atanl( long double arg );</pre>
</td> <td> (3) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr> <tr class="t-dcl t-since-c23"> <td> <pre data-language="c">_Decimal32  atand32( _Decimal32 arg );</pre>
</td> <td> (4) </td> <td> <span class="t-mark-rev t-since-c23">(since C23)</span> </td> </tr> <tr class="t-dcl t-since-c23"> <td> <pre data-language="c">_Decimal64  atand64( _Decimal64 arg );</pre>
</td> <td> (5) </td> <td> <span class="t-mark-rev t-since-c23">(since C23)</span> </td> </tr> <tr class="t-dcl t-since-c23"> <td> <pre data-language="c">_Decimal128 atand128( _Decimal128 arg );</pre>
</td> <td> (6) </td> <td> <span class="t-mark-rev t-since-c23">(since C23)</span> </td> </tr> <tr class="t-dsc-header"> <th> Defined in header <code>&lt;tgmath.h&gt;</code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c99"> <td> <pre data-language="c">#define atan( arg )</pre>
</td> <td> (7) </td> <td> <span class="t-mark-rev t-since-c99">(since C99)</span> </td> </tr>  </table> <div class="t-li1">
<span class="t-li">1-6)</span> Computes the principal value of the arc tangent of <code>arg</code>.</div> <div class="t-li1">
<span class="t-li">7)</span> Type-generic macro: If the argument has type <code>long double</code>, <span class="t-v">(3)</span> (atanl) is called. Otherwise, if the argument has integer type or the type <code>double</code>, <span class="t-v">(2)</span> (<code>atan</code>) is called. Otherwise, <span class="t-v">(1)</span> (<code>atanf</code>) is called. If the argument is complex, then the macro invokes the corresponding complex function (<code><a href="../complex/catan" title="c/numeric/complex/catan">catanf</a></code>, <code><a href="../complex/catan" title="c/numeric/complex/catan">catan</a></code>, <code><a href="../complex/catan" title="c/numeric/complex/catan">catanl</a></code>).</div> <table class="t-rev-begin"> <tr class="t-rev t-since-c23">
<td> <p>The functions <span class="t-v">(4-6)</span> are declared if and only if the implementation predefines <code>__STDC_IEC_60559_DFP__</code> (i.e. the implementation supports decimal floating-point numbers).</p>
</td> <td><span class="t-mark-rev t-since-c23">(since C23)</span></td>
</tr> </table>  <h3 id="Parameters"> Parameters</h3> <table class="t-par-begin"> <tr class="t-par"> <td> arg </td> <td> - </td> <td> floating point value </td>
</tr>
</table> <h3 id="Return_value"> Return value</h3> If no errors occur, the arc tangent of <code>arg</code> (arctan(arg)) in the range [- <span><span>π</span><span>/</span><span>2</span></span> ; +<span><span>π</span><span>/</span><span>2</span></span>] radians, is returned. <p>If a range error occurs due to underflow, the correct result (after rounding) is returned.</p>
<h3 id="Error_handling"> Error handling</h3> <p>Errors are reported as specified in <a href="math_errhandling" title="c/numeric/math/math errhandling"><code>math_errhandling</code></a>.</p>
<p>If the implementation supports IEEE floating-point arithmetic (IEC 60559):</p>
<ul>
<li> if the argument is ±0, it is returned unmodified; </li>
<li> if the argument is +∞, +π/2 is returned; </li>
<li> if the argument is -∞, -π/2 is returned; </li>
<li> if the argument is NaN, NaN is returned. </li>
</ul> <h3 id="Notes"> Notes</h3> <p><a rel="nofollow" class="external text" href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/atan.html">POSIX specifies</a> that in case of underflow, <code>arg</code> is returned unmodified, and if that is not supported, an implementation-defined value no greater than <code><a href="../../types/limits" title="c/types/limits">DBL_MIN</a></code>, <code><a href="../../types/limits" title="c/types/limits">FLT_MIN</a></code>, and <code><a href="../../types/limits" title="c/types/limits">LDBL_MIN</a></code> is returned.</p>
<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;math.h&gt;
#include &lt;stdio.h&gt;
 
int main(void)
{
    printf("atan(1) = %f, 4*atan(1)=%f\n", atan(1), 4 * atan(1));
    // special values
    printf("atan(Inf) = %f, 2*atan(Inf) = %f\n", atan(INFINITY), 2 * atan(INFINITY));
    printf("atan(-0.0) = %+f, atan(+0.0) = %+f\n", atan(-0.0), atan(0));
}</pre></div> <p>Output:</p>
<div class="text source-text"><pre data-language="c">atan(1) = 0.785398, 4*atan(1)=3.141593
atan(Inf) = 1.570796, 2*atan(Inf) = 3.141593
atan(-0.0) = -0.000000, atan(+0.0) = +0.000000</pre></div> </div> <h3 id="References"> References</h3>  <ul>
<li> C23 standard (ISO/IEC 9899:2023): </li>
<ul>
<li> 7.12.4.3 The atan functions (p: TBD) </li>
<li> 7.25 Type-generic math &lt;tgmath.h&gt; (p: TBD) </li>
<li> F.10.1.3 The atan functions (p: TBD) </li>
</ul>
<li> C17 standard (ISO/IEC 9899:2018): </li>
<ul>
<li> 7.12.4.3 The atan functions (p: 174) </li>
<li> 7.25 Type-generic math &lt;tgmath.h&gt; (p: 272-273) </li>
<li> F.10.1.3 The atan functions (p: 378) </li>
</ul>
<li> C11 standard (ISO/IEC 9899:2011): </li>
<ul>
<li> 7.12.4.3 The atan functions (p: 238-239) </li>
<li> 7.25 Type-generic math &lt;tgmath.h&gt; (p: 373-375) </li>
<li> F.10.1.3 The atan functions (p: 519) </li>
</ul>
<li> C99 standard (ISO/IEC 9899:1999): </li>
<ul>
<li> 7.12.4.3 The atan functions (p: 219) </li>
<li> 7.22 Type-generic math &lt;tgmath.h&gt; (p: 335-337) </li>
<li> F.9.1.3 The atan functions (p: 456) </li>
</ul>
<li> C89/C90 standard (ISO/IEC 9899:1990): </li>
<ul><li> 4.5.2.3 The atan function </li></ul>
</ul>                           <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="atan2" title="c/numeric/math/atan2"> <span class="t-lines"><span>atan2</span><span>atan2f</span><span>atan2l</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> computes arc tangent, using signs to determine quadrants <br> <span class="t-mark">(function)</span>  </td>
</tr> <tr class="t-dsc"> <td> <div><a href="asin" title="c/numeric/math/asin"> <span class="t-lines"><span>asin</span><span>asinf</span><span>asinl</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> computes arc sine (\({\small\arcsin{x} }\)arcsin(x)) <br> <span class="t-mark">(function)</span>  </td>
</tr> <tr class="t-dsc"> <td> <div><a href="acos" title="c/numeric/math/acos"> <span class="t-lines"><span>acos</span><span>acosf</span><span>acosl</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> computes arc cosine (\({\small\arccos{x} }\)arccos(x)) <br> <span class="t-mark">(function)</span>  </td>
</tr> <tr class="t-dsc"> <td> <div><a href="tan" title="c/numeric/math/tan"> <span class="t-lines"><span>tan</span><span>tanf</span><span>tanl</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> computes tangent (\({\small\tan{x} }\)tan(x)) <br> <span class="t-mark">(function)</span>  </td>
</tr> <tr class="t-dsc"> <td> <div><a href="../complex/catan" title="c/numeric/complex/catan"> <span class="t-lines"><span>catan</span><span>catanf</span><span>catanl</span></span></a></div>
<div><span class="t-lines"><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span><span><span class="t-mark-rev t-since-c99">(C99)</span></span></span></div> </td> <td> computes the complex arc tangent <br> <span class="t-mark">(function)</span>  </td>
</tr> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/numeric/math/atan" title="cpp/numeric/math/atan">C++ documentation</a></span> for <code>atan</code> </td>
</tr> </table>           <div class="_attribution">
  <p class="_attribution-p">
    &copy; cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br>
    <a href="https://en.cppreference.com/w/c/numeric/math/atan" class="_attribution-link">https://en.cppreference.com/w/c/numeric/math/atan</a>
  </p>
</div>