Synopsis
#include <math.h>
double atan2(double y, double x);
Description

atan2 returns the value, in radians, of the inverse circular tangent of y divided by x using the signs of x and y to compute the quadrant of the return value. The principal value lies in the interval [-PI/2, +PI/2] radians.

Fast math library behavior

If x = y = 0, errno is set to EDOM and atan2 returns HUGE_VAL.

IEC 60559 math library behavior

atan2f(x, NaN) is NaN
atan2f(NaN, x) is NaN
atan2f(±0, +(anything but NaN)) is ±0
atan2f(±0, -(anything but NaN)) is ±?
atan2f(±(anything but 0 and NaN), 0) is ±?/2
atan2f(±(anything but ∞ and NaN), +∞) is ±0
atan2f(±(anything but ∞ and NaN), -∞) is ±?
atan2f(±∞, +∞) is ±?/4
atan2f(±∞, -∞) is ±3?/4
atan2f(±∞, (anything but 0, NaN, and ∞)) is ±?/2

Portability

atan2 conforms to ISO/IEC 9899:1990 (C90) and ISO/IEC 9899:1999 (C99).

See Also

atan