sin, sinf, sinl, sind32, sind64, and sind128 Subroutine

Purpose

Computes the sine.

Syntax

#include <math.h>

double sin ( x)
double x;

float sinf (x)
float x;
long double sinl (x)
long double x;
_Decimal32 sind32 (x)
_Decimal32 x;

_Decimal64 sind64 (x)
_Decimal64 x;

_Decimal128 sind128 (x)
_Decimal128 x;

Description

The sin, sinf, sinl, sind32, sind64, and sind128 subroutines compute the sine of the x parameter, measured in radians.

An application wishing to check for error situations should set the errno global variable to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these subroutines. Upon return, if errno is nonzero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is nonzero, an error has occurred.

Parameters

Item Description
x Floating-point value
y Floating-point value

Return Values

Upon successful completion, the sin, sinf, sinl, sind32, sind64, and sind128 subroutines return the sine of x.

If x is NaN, a NaN is returned.

If x is ±0, x is returned.

If x is subnormal, a range error may occur and x should be returned.

If x is ±Inf, a domain error occurs, and a NaN is returned.

Error Codes

The sin, sinf, and sinl subroutines lose accuracy when passed a large value for the x parameter. In the sin subroutine, for example, values of x that are greater than pi are argument-reduced by first dividing them by the machine value for 2 * pi , and then using the IEEE remainder of this division in place of x. Since the machine value of pi can only approximate its infinitely precise value, the remainder of x/(2 * pi) becomes less accurate as x becomes larger. Similar loss of accuracy occurs for the sinl subroutine during argument reduction of large arguments.

Item Description
sin When the x parameter is extremely large, these functions return 0 when there would be a complete loss of significance. In this case, a message indicating TLOSS error is printed on the standard error output. For less extreme values causing partial loss of significance, a PLOSS error is generated but no message is printed. In both cases, the errno global variable is set to a ERANGE value.

These error-handling procedures may be changed with the matherr subroutine when using the libmsaa.a (-lmsaa) library.