summaryrefslogtreecommitdiff
path: root/devdocs/c/numeric%2Fmath%2Ftan.html
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
committerCraig Jennings <c@cjennings.net>2024-04-07 13:41:34 -0500
commit754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch)
treef1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/c/numeric%2Fmath%2Ftan.html
new repository
Diffstat (limited to 'devdocs/c/numeric%2Fmath%2Ftan.html')
-rw-r--r--devdocs/c/numeric%2Fmath%2Ftan.html106
1 files changed, 106 insertions, 0 deletions
diff --git a/devdocs/c/numeric%2Fmath%2Ftan.html b/devdocs/c/numeric%2Fmath%2Ftan.html
new file mode 100644
index 00000000..74007697
--- /dev/null
+++ b/devdocs/c/numeric%2Fmath%2Ftan.html
@@ -0,0 +1,106 @@
+ <h1 id="firstHeading" class="firstHeading">tan, tanf, tanl</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 tanf( 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 tan( 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 tanl( 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 tand32( _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 tand64( _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 tand128( _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 tan( 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 tangent of <code>arg</code> (measured in radians).</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> (<code>tanl</code>) is called. Otherwise, if the argument has integer type or the type <code>double</code>, <span class="t-v">(2)</span> (<code>tan</code>) is called. Otherwise, <span class="t-v">(1)</span> (<code>tanf</code>) is called. If the argument is complex, then the macro invokes the corresponding complex function (<code><a href="../complex/ctan" title="c/numeric/complex/ctan">ctanf</a></code>, <code><a href="../complex/ctan" title="c/numeric/complex/ctan">ctan</a></code>, <code><a href="../complex/ctan" title="c/numeric/complex/ctan">ctanl</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 representing angle in radians </td>
+</tr>
+</table> <h3 id="Return_value"> Return value</h3> <p>If no errors occur, the tangent of <code>arg</code> (tan(arg)) is returned.</p>
+<table class="t-rev-begin"> <tr class="t-rev t-until-c99">
+<td> <p>The result may have little or no significance if the magnitude of <code>arg</code> is large.</p>
+</td> <td><span class="t-mark-rev t-until-c99">(until C99)</span></td>
+</tr> </table> <p>If a domain error occurs, an implementation-defined value is returned (NaN where supported).</p>
+<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 ±∞, NaN is returned and <code><a href="../fenv/fe_exceptions" title="c/numeric/fenv/FE exceptions">FE_INVALID</a></code> is raised; </li>
+<li> if the argument is NaN, NaN is returned. </li>
+</ul> <h3 id="Notes"> Notes</h3> <p>The case where the argument is infinite is not specified to be a domain error in C, but it is defined as a <a rel="nofollow" class="external text" href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/tan.html">domain error in POSIX</a>.</p>
+<p>The function has mathematical poles at π(1/2 + n); however no common floating-point representation is able to represent <code>π/2</code> exactly, thus there is no value of the argument for which a pole error occurs.</p>
+<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include &lt;errno.h&gt;
+#include &lt;fenv.h&gt;
+#include &lt;math.h&gt;
+#include &lt;stdio.h&gt;
+
+#ifndef __GNUC__
+#pragma STDC FENV_ACCESS ON
+#endif
+
+int main(void)
+{
+ const double pi = acos(-1);
+
+ // typical usage
+ printf("tan(pi*1/4) = %+f\n", tan(pi * 1 / 4)); // 45 deg
+ printf("tan(pi*3/4) = %+f\n", tan(pi * 3 / 4)); // 135 deg
+ printf("tan(pi*5/4) = %+f\n", tan(pi * 5 / 4)); // -135 deg
+ printf("tan(pi*7/4) = %+f\n", tan(pi * 7 / 4)); // -45 deg
+
+ // special values
+ printf("tan(+0) = %f\n", tan(0.0));
+ printf("tan(-0) = %f\n", tan(-0.0));
+
+ // error handling
+ feclearexcept(FE_ALL_EXCEPT);
+ printf("tan(INFINITY) = %f\n", tan(INFINITY));
+ if (fetestexcept(FE_INVALID))
+ puts(" FE_INVALID raised");
+}</pre></div> <p>Possible output:</p>
+<div class="text source-text"><pre data-language="c">tan(pi*1/4) = +1.000000
+tan(pi*3/4) = -1.000000
+tan(pi*5/4) = +1.000000
+tan(pi*7/4) = -1.000000
+tan(+0) = 0.000000
+tan(-0) = -0.000000
+tan(INFINITY) = -nan
+ FE_INVALID raised</pre></div> </div> <h3 id="References"> References</h3> <ul>
+<li> C23 standard (ISO/IEC 9899:2023): </li>
+<ul>
+<li> 7.12.4.7 The tan functions (p: TBD) </li>
+<li> 7.25 Type-generic math &lt;tgmath.h&gt; (p: TBD) </li>
+<li> F.10.1.7 The tan functions (p: TBD) </li>
+</ul>
+<li> C17 standard (ISO/IEC 9899:2018): </li>
+<ul>
+<li> 7.12.4.7 The tan functions (p: 175) </li>
+<li> 7.25 Type-generic math &lt;tgmath.h&gt; (p: 272-273) </li>
+<li> F.10.1.7 The tan functions (p: 378) </li>
+</ul>
+<li> C11 standard (ISO/IEC 9899:2011): </li>
+<ul>
+<li> 7.12.4.7 The tan functions (p: 240) </li>
+<li> 7.25 Type-generic math &lt;tgmath.h&gt; (p: 373-375) </li>
+<li> F.10.1.7 The tan functions (p: 519) </li>
+</ul>
+<li> C99 standard (ISO/IEC 9899:1999): </li>
+<ul>
+<li> 7.12.4.7 The tan functions (p: 220) </li>
+<li> 7.22 Type-generic math &lt;tgmath.h&gt; (p: 335-337) </li>
+<li> F.9.1.7 The tan functions (p: 457) </li>
+</ul>
+<li> C89/C90 standard (ISO/IEC 9899:1990): </li>
+<ul><li> 4.5.2.7 The tan function </li></ul>
+</ul> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td> <div><a href="sin" title="c/numeric/math/sin"> <span class="t-lines"><span>sin</span><span>sinf</span><span>sinl</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 sine (\({\small\sin{x} }\)sin(x)) <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="cos" title="c/numeric/math/cos"> <span class="t-lines"><span>cos</span><span>cosf</span><span>cosl</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 cosine (\({\small\cos{x} }\)cos(x)) <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="atan" title="c/numeric/math/atan"> <span class="t-lines"><span>atan</span><span>atanf</span><span>atanl</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 (\({\small\arctan{x} }\)arctan(x)) <br> <span class="t-mark">(function)</span> </td>
+</tr> <tr class="t-dsc"> <td> <div><a href="../complex/ctan" title="c/numeric/complex/ctan"> <span class="t-lines"><span>ctan</span><span>ctanf</span><span>ctanl</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 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/tan" title="cpp/numeric/math/tan">C++ documentation</a></span> for <code>tan</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/tan" class="_attribution-link">https://en.cppreference.com/w/c/numeric/math/tan</a>
+ </p>
+</div>