# atan2

function
```<cmath> ```
```     double atan2 (      double y,      double x );
long double atan2 ( long double y, long double x );
float atan2 (       float y,       float x );```

Compute arc tangent with two parameters

Returns the principal value of the arc tangent of y/x, expressed in radians.

To compute the value, the function uses the sign of both arguments to determine the quadrant.

In C++, this function is overloaded in <valarray> (see valarray atan2).

### Parameters

y
Floating point value representing an y-coordinate.
x
Floating point value representing an x-coordinate.

If both arguments passed are zero, a domain error occurs, which sets the global variable ERRNO to the EDOM value.

### Return Value

Principal arc tangent of y/x, in the interval [-pi,+pi] radians.

### Portability

In C, only the double version of this function exists with this name.

### Example

 123456789101112131415 ``````/* atan2 example */ #include #include #define PI 3.14159265 int main () { double x, y, result; x = -10.0; y = 10.0; result = atan2 (y,x) * 180 / PI; printf ("The arc tangent for (x=%lf, y=%lf) is %lf degrees\n", x, y, result ); return 0; }``````

Output:
 ``` The arc tangent for (x=-10.000000, y=10.000000) is 135.000000 degrees. ```