tan, tanf, tanl, tand32, tand64, and tand128 Subroutines

Purpose

Computes the tangent.

Syntax

#include <math.h>

float tanf (x)
float x;

long double tanl (x)
long double x;

double tan (x)
double x;_Decimal32 tand32 (x)
_Decimal32 x;

_Decimal64 tand64 (x)
_Decimal64 x;

_Decimal128 tand128 (x)
_Decimal128 x;

Description

The tan, tanf, tanl, tand32, tand64, and tand128 subroutines compute the tangent 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 functions. 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 Specifies the value to be computed.

Return Values

Upon successful completion, the tan, tanf, tanl, tand32, tand64, and tand128 subroutines return the tangent of x.

If the correct value would cause underflow, and is not representable, a range error may occur, and 0.0 is returned.

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 returned.

If the correct value would cause underflow, and is representable, a range error may occur and the correct value is returned.

If the correct value would cause overflow, a range error occurs and the tan, tanf, tanl, tand32, tand64, and tand128 subroutines return the value of the macro HUGE_VAL, HUGE_VALF, HUGE_VALL, HUGE_VAL_D32, HUGE_VAL_D64, and HUGE_VAL_D128 respectively.

Error Codes

The tan, tanf, and tanl subroutines lose accuracy when passed a large value for the x parameter. 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 tan, tanf, and tanl subroutines during argument reduction of large arguments.