15.5. acos(), acosf(), acosl()

Calculate the arc cosine of a number.

Prototypes

#include <math.h>
double acos(double x);
float acosf(float x);
long double acosl(long double x);

Description

Calculates the arc cosine of a number in radians. (That is, the value whose cosine is x.) The number must be in the range -1.0 to 1.0.

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 arc cosine of x, unless x is out of range. In that case, errno will be set to EDOM and the return value will be NaN. The variants return different types.

Example

double acosx;
long double ldacosx;

acosx = acos(0.2);
ldacosx = acosl((long double)0.3);

See Also

asin(), atan(), atan2(), cos()