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
|
<h1 id="firstHeading" class="firstHeading">sinpi, sinpif, sinpil, sinpid32, sinpid64, sinpid128</h1> <table class="t-dcl-begin"> <tr class="t-dsc-header"> <th> Defined in header <code><math.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c23"> <td> <pre data-language="c">float sinpif( float arg );</pre>
</td> <td> (1) </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">double sinpi( double arg );</pre>
</td> <td> (2) </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">long double sinpil( long double arg );</pre>
</td> <td> (3) </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">_Decimal32 sinpid32( _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 sinpid64( _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 sinpid128( _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><tgmath.h></code> </th> <th> </th> <th> </th> </tr> <tr class="t-dcl t-since-c23"> <td> <pre data-language="c">#define sinpi( arg )</pre>
</td> <td> (7) </td> <td> <span class="t-mark-rev t-since-c23">(since C23)</span> </td> </tr> </table> <div class="t-li1">
<span class="t-li">1-6)</span> Computes the sine of <code>π·arg</code> measured in radians, thus regarding <code>arg</code> as a measurement in half-revolutions.</div> <div class="t-li1">
<span class="t-li">7)</span> Type-generic macro: calls the correct function based on the type of <code>arg</code>. If the argument has integer type, <span class="t-v">(2)</span> is called.</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 whose product with <code>π</code> represents an angle in radians </td>
</tr>
</table> <h3 id="Return_value"> Return value</h3> <p>If no errors occur, the sine of <code>π·arg</code> (sin(π×arg)) in the range [-1, +1], 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="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <errno.h>
#include <fenv.h>
#include <math.h>
#include <stdio.h>
#ifndef __GNUC__
#pragma STDC FENV_ACCESS ON
#endif
#if __STDC_VERSION__ < 202311L
// A naive implementation of a subset of sinpi family
double sinpi(double arg)
{
return sin(arg * (double)3.1415926535897932384626433);
}
#endif
int main(void)
{
const double pi = acos(-1);
// typical usage
printf("sinpi(1) = %f, sin(pi) = %f\n", sinpi(1), sin(pi));
printf("sinpi(0.5) = %f, sin(pi/2) = %f\n", sinpi(0.5), sin(pi / 2));
printf("sinpi(-0.75) = %f, sin(-3*pi/4) = %f\n", sinpi(-0.75), sin(-3 * pi / 4));
// special values
printf("sinpi(+0) = %f\n", sinpi(0.0));
printf("sinpi(-0) = %f\n", sinpi(-0.0));
// error handling
feclearexcept(FE_ALL_EXCEPT);
printf("sinpi(INFINITY) = %f\n", sinpi(INFINITY));
if (fetestexcept(FE_INVALID))
puts(" FE_INVALID raised");
}</pre></div> <p>Possible output:</p>
<div class="text source-text"><pre data-language="c">sinpi(1) = 0.000000, sin(pi) = 0.000000
sinpi(0.5) = 1.000000, sin(pi/2) = 1.000000
sinpi(-0.75) = -0.707107, sin(-3*pi/4) = -0.707107
sinpi(+0) = 0.000000
sinpi(-0) = -0.000000
sinpi(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.13 The sinpi functions (p: 247-248) </li>
<li> 7.27 Type generic math <tgmath.h> (p: 387) </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> </table> <div class="_attribution">
<p class="_attribution-p">
© 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/sinpi" class="_attribution-link">https://en.cppreference.com/w/c/numeric/math/sinpi</a>
</p>
</div>
|