15.3. tan(), tanf(), tanl()

Calculate the tangent of a number.

Prototypes

#include <math.h>
double tan(double x)
float tanf(float x)
long double tanl(long double x)

Description

Calculates the tangent of the value x, where x is in radians.

For those of you who don't remember, radians are another way of measuring an angle, just like degrees. To convert from degrees to radians or the other way around, use the following code:

degrees = radians * 180.0f / M_PI;
radians = degrees * M_PI / 180;

Return Value

Returns the tangent of x. The variants return different types.

Example

double tanx;
long double ldtanx;

tanx = tan(3490.0); // round and round we go!
ldtanx = tanl((long double)3.490);

See Also

sin(), cos(), atan(), atan2()