atan2, atan2l
raw OCR
Calculates the arc tangent of ylx.
Defined in header <math.h>
Syntax
#include <math.h>
double atan2(double y, double x);
long double atan21(long double y, long double x);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only | |
|---|---|---|---|---|---|
| atan2 | ■ | ■ | ■ | ■ | |
| atan2l | ■ | ■ |
Remarks
atan2 returns the arc tangent of y/x; it produces correct results even when the resulting angle is near pi/2 or -pi/2 (x near 0).
If both X and y are set to 0, the function sets the global variable errno to EDOM.
atan2l is the long double version; it takes long double arguments and returns a long double result.
Return value
atan2 and atan2l return a value in the range -pi to pi.
Error handling for these functions can be modified through the functions matherr and _matherrl.
See also
Example
#include <stdio.h>
#include <math.h>
int main(void)
{
double result, x = 90.0, y = 15.0;
result = atan2(y, x);
printfC'The arc tangent ratio of %lf is %lf\n", (y/x), result);
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/math.h/atan2/
· short form /3.1/atan2/