Format
#include <math.h> double sin(double x); float sinf(float x); long double sinl(long double x);float sin(float x);
long double sin(long double x);
Language Level: ANSI, POSIX, XPG4
sin calculates the sine of x, with x
expressed in radians.
The absolute value of the argument x must be less than 263.
If x is too large, a partial loss of significance in the result may occur.
Note:
C++ prototypes
float sin(float x); long double sin(long double x);
are disabled when you compile using the lang(compatmath) option.
Return Value
sin returns the value of the sine of x.
If the absolute value of the argument is more than 263, then errno is set to EDOM and sin returns NaN.
Example
This example computes y as the sine of pi/2.
#include <math.h> #include <stdio.h>
int main(void)
{
double pi, x, y;
pi = 3.1415926535; x = pi/2; y = sin(x);
printf("sin( %lf ) = %lf\n", x, y);
return 0;
/***************************************
The output should be:
sin( 1.570796 ) = 1.000000 ***************************************/ }
![]()
acos -- Calculate Arccosine
asin -- Calculate Arcsine
atan - atan2 -- Calculate Arctangent
cos -- Calculate Cosine
cosh -- Calculate Cosine
_fasin -- Calculate Arcsine
_fcossin -- Calculate Cosine and Sine
_fsin -- Calculate Sine
_fsincos -- Calculate Sine and Cosine
sinh -- Calculate Hyperbolic Sine
tan -- Calculate Tangent
tanh -- Calculate Hyperbolic Tangent
<math.h>
lang(compatmath) option
