Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C |
both |
#include <math.h>
double atan(double x);
float atan(float x); /* C++ only */
long double atan(long double x); /* C++ only */
float atanf(float x);
long double atanl(long double x);
double atan2(double y, double x);
float atan2(float y, float x); /* C++ only */
long double atan2(long double y, long double x); /* C++ only */
float atan2f(float y, float x);
long double atan2l(long double y, long double x);
Returns a value in the range -pi/2 to pi/2 radians.
The atan2() functions return a value in the range -pi to pi radians. If both arguments of atan2() are zero, the function sets errno to EDOM, and returns 0. If the correct value would cause underflow, zero is returned and the value ERANGE is stored in errno.
Special behavior for IEEE: If successful, atan2() returns the arctangent of y/x.
If both arguments of atan2() are zero, the function sets errno to EDOM and returns 0. No other errors will occur.
⁄* CELEBA09 *⁄
#include <math.h>
#include <stdio.h>
int main(void)
{
double a,b,c,d;
c = 0.45;
d = 0.23;
a = atan(c);
b = atan2(c,d);
printf("atan( %f ) = %f\n", c, a);
printf("atan2( %f, %f ) = %f\n", c, d, b);
}
atan( 0.450000 ) = 0.422854
atan2( 0.450000, 0.230000 ) = 1.098299