sin, sinf, sinl

Calculates the sine of a floating-point value.


double sin(double x);
float sinf(float x);
long double sinl(long double x);
float sin(float x);  // C++ only
long double sin(long double x);  // C++ only


Angle in radians.

Return value

The sin functions return the sine of x. If x is greater than or equal to 263, or less than or equal to -263, a loss of significance in the result occurs.

Input SEH Exception Matherr Exception
± ∞ (sin, sinf, sinl) INVALID _DOMAIN

For more information about return codes, see errno, _doserrno, _sys_errlist, and _sys_nerr.


Because C++ allows overloading, you can call overloads of sin that take and return float or long double values. In a C program, sin always takes and returns double.


Routine Required header (C) Required header (C++)
sin, sinf, sinl <math.h> <cmath> or <math.h>

For additional compatibility information, see Compatibility.


// crt_sincos.c
// This program displays the sine and cosine of pi / 2.
// Compile by using: cl /W4 crt_sincos.c

#include <math.h>
#include <stdio.h>

int main( void)
   double pi = 3.1415926535;
   double x, y;

   x = pi / 2;
   y = sin( x );
   printf( "sin( %f ) = %f\n", x, y );
   y = cos( x );
   printf( "cos( %f ) = %f\n", x, y );
sin( 1.570796 ) = 1.000000
cos( 1.570796 ) = 0.000000

See also

Floating-Point Support
acos, acosf, acosl
asin, asinf, asinl
atan, atanf, atanl, atan2, atan2f, atan2l
cos, cosf, cosl
tan, tanf, tanl