atan2, atan2l

De Appmethod Topics
Aller à : navigation, rechercher

Remonter à Math.h - Index


Header File

math.h

Category

Math Routines

Prototype

double atan2(double y, double x);

long double atan2l(long double y, long double x);

Description

Calculates the arc tangent of y/x.

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, indicating a domain error.

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.

Example



 #include <stdio.h>
 #include <math.h>
 int main(void)
 {
    double result;
    double x = 90.0, y = 45.0;
    result = atan2(y, x);
    printf("The arc tangent ratio of %lf is %lf\n", (y / x), result);
    return 0;
 }



Portability



POSIX Win32 ANSI C ANSI C++

atan2

+

+

+

+

atan2l

+

+

+