Computes the arc tangent.
#include <math.h>
float atan2f (y, x)
float y, float x;
long double atan2l (y, x)
long double y, long double x;
double atan2 (y, x)
double y, x;
_Decimal32 atan2d32 (y, x)
_Decimal32 y, x;
_Decimal64 atan2d64 (y, x)
_Decimal64 y, x;
_Decimal128 atan2d128 (y, x)
_Decimal128 y, x;
The atan2f, atan2l, atan2, atan2d32, atan2d64 and atan2d128 subroutines compute the principal value of the arc tangent of y/x, using the signs of both parameters to determine the quadrant of the return value.
An application wishing to check for error situations should set the errno global variable to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. On return, if errno is nonzero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is nonzero, an error has occurred.
Item | Description |
---|---|
y | Specifies the value to compute. |
x | Specifies the value to compute. |
Upon successful completion, the atan2f, atan2l, atan2, atan2d32, atan2d64, and atan2d128 subroutines return the arc tangent of y/x in the range [-pi, pi] radians.
If y is 0 and x is < 0, ±pi is returned.
If y is 0 and x is > 0, 0 is returned.
If y is < 0 and x is 0, -pi/2 is returned.
If y is > 0 and x is 0, pi/2 is returned.
If x is 0, a pole error does not occur.
If either x or y is NaN, a NaN is returned.
If the result underflows, a range error may occur and y/x is returned.
If y is 0 and x is -0, ±x is returned.
If y is 0 and x is +0, 0 is returned.
For finite values of ±y >0, if x is -Inf, ±x is returned.
For finite values of ±y >0, if x is +Inf, 0 is returned.
For finite values of x, if y is ±Inf, ±x/2 is returned.
If y is ±Inf and x is -Inf, ±3pi/4 is returned.
If y is ±Inf and x is +Inf, ±pi/4 is returned.
If both arguments are 0, a domain error does not occur.