15.2. cos(), cosf(), cosl()

Calculate the cosine of a number.


#include <math.h>
double cos(double x)
float cosf(float x)
long double cosl(long double x)


Calculates the cosine 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 cosine of x. The variants return different types.


double sinx;
long double ldsinx;

sinx = sin(3490.0); // round and round we go!
ldsinx = sinl((long double)3.490);

See Also

sin(), tan(), acos()