tan(), tanf(), tanl() — Calculate tangent
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C |
both |
Format
#include <math.h>
double tan(double x);
float tan(float x); /* C++ only */
long double tan(long double x); /* C++ only */
float tanf(float x);
long double tanl(long double x);
General description
Calculates the tangent
of x, where x is
expressed in radians. If x is large, a partial
loss of significance in the result can occur.
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
Returns the calculated tangent of x.
If the correct value would cause an underflow, 0 is returned. If the result overflows, ±HUGE_VAL is returned. For both an underflow and an overflow, the value ERANGE is stored in errno.
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
CELEBT01
/* CELEBT01
This example computes x as the tangent of PI/4.
*/
#include <math.h>
#include <stdio.h>
int main(void)
{
double pi, x;
pi = 3.1415926;
x = tan(pi/4.0);
printf("tan( %lf ) is %lf\n", pi/4, x);
}
Output
tan( 0.785398 ) is 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
- sin(), sinf(), sinl() — Calculate sine
- sinh(), sinhf(), sinhl() — Calculate hyperbolic sine
- tanh(), tanhf(), tanhl() — Calculate hyperbolic tangent