sin(), sinf(), sinl() — Calculate sine
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C |
both |
Format
#include <math.h>
double sin(double x);
float sin(float x); /* C++ only */
long double sin(long double x); /* C++ only */
float sinf(float x);
long double sinl(long double x);
General description
Calculates the sine
of x, with x expressed
in radians.
Note: These functions work in both IEEE Binary Floating-Point
and hexadecimal floating-point formats. See IEEE binary floating-point for more information about IEEE
Binary Floating-Point.
Returned value
If successful, the function returns the calculated value, expressed as a double, float, or long double. Otherwise, if the result is an underflow, the function returns 0 and sets the errno to ERANGE.
Special Behavior for XPG4.2: The
following error is added:
- Error Code
- Description
- EDOM
- The argument exceeded an internal limit for the function (approximately 250).
Example
CELEBS27
/* CELEBS27
This example computes y as the sine of &pi.&slr.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);
}
Output
sin( 1.570796 ) = 1.000000
Related information
- math.h
- acos(), acosf(), acosl() — Calculate arccosine
- acosh(), acoshf(), acoshl() — Calculate hyperbolic arccosine
- asin(), asinf(), asinl() — Calculate arcsine
- asinh(), asinhf(), asinhl() — Calculate hyperbolic arcsine
- atan(), atanf(), atanl(), atan2(), atan2f(), atan2l() — Calculate arctangent
- atanh(), atanhf(), atanhl() — Calculate hyperbolic arctangent
- cos(), cosf(), cosl() — Calculate cosine
- cosh(), coshf(), coshl() — Calculate hyperbolic cosine
- sinh(), sinhf(), sinhl() — Calculate hyperbolic sine
- tan(), tanf(), tanl() — Calculate tangent
- tanh(), tanhf(), tanhl() — Calculate hyperbolic tangent