sin, sinf, sinl

Header: <math.h>

1-3) Computes the sine of arg (measured in radians).

# Declarations

float sinf( float arg );

(since C99)

double sin( double arg );
long double sinl( long double arg );

(since C99)

_Decimal32 sind32( _Decimal32 arg );

(since C23)

_Decimal64 sind64( _Decimal64 arg );

(since C23)

_Decimal128 sind128( _Decimal128 arg );

(since C23)

#define sin( arg )

(since C99)

# Parameters

# Return value

If no errors occur, the sine of arg (sin(arg)) in the range [-1 ; +1], is returned.

# Notes

The case where the argument is infinite is not specified to be a domain error in C, but it is defined as a domain error in POSIX.

POSIX also specifies that in case of underflow, arg is returned unmodified, and if that is not supported, an implementation-defined value no greater than DBL_MIN, FLT_MIN, and LDBL_MIN is returned.

# Example

#include <errno.h>
#include <fenv.h>
#include <math.h>
#include <stdio.h>
 
#ifndef __GNUC__
#pragma STDC FENV_ACCESS ON
#endif
 
int main(void)
{
    const double pi = acos(-1);
 
    // typical usage
    printf("sin(pi/6) = %f\n", sin(pi / 6));
    printf("sin(pi/2) = %f\n", sin(pi / 2));
    printf("sin(-3*pi/4) = %f\n", sin(-3 * pi / 4));
 
    // special values
    printf("sin(+0) = %f\n", sin(0.0));
    printf("sin(-0) = %f\n", sin(-0.0));
 
    // error handling
    feclearexcept(FE_ALL_EXCEPT);
    printf("sin(INFINITY) = %f\n", sin(INFINITY));
    if (fetestexcept(FE_INVALID))
        puts("    FE_INVALID raised");
}

# See also