Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C |
both |
#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);
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.
⁄* 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);
}
tan( 0.785398 ) is 1.000000