Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

atan2, atan2f, atan2l - Arc tangent of x/y

&pagelevel(4)&pagelevel

Definition  

#include <math.h>

double atan2(double x, double y);float atanf(float x); (C11)
long double atanl(long double x); (C11)

These functions calculate the arc tangent of x/y. The signs of the two arguments determine the resulting quadrants.

Return val.

arc tangent(x/y)



a floating-point number of type double in the interval [-pi/2, +pi/2].
If the divisor y is equal to 0, atan2 returns either -pi/2 or +pi/2, depending on the sign of the dividend.


0

if the dividend x is equal to 0.


pi/2

if both arguments are equal to 0. errno is set to EDOM (domain error).

Example

The following program reads in the arguments x and y and prints the computed arc tangent of x/y.

#include <math.h>
#include <stdio.h>
int main(void)
{
  double x, y;
  printf("Example of ATAN2(x/y)\n");
  printf("Enter x and y please:\n");
  if (scanf("%lf %lf", &x, &y) == 2)
       printf("ATAN2 (%g / %g) = %g\n", x, y, atan2(x, y));
  return 0;
}

See also

atan, tan, sin, asin, cos, acos