[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1

atan2f, atan2l, or atan2 Subroutine

Purpose

Computes the arc tangent.

Syntax

#include <math.h>

float atan2f (y, x)
float y, float x;

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

double atan2 (y, x)
double y, x;

Description

The atan2f, atan2l, and atan2 subroutines compute the principal value of the arc tangent of y/x, using the signs of both parameters to determine the quadrant of the return value.

An application wishing to check for error situations should set the errno global variable to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. On return, if errno is nonzero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is nonzero, an error has occurred.

Parameters

y Specifies the value to compute.
x Specifies the value to compute.

Return Values

Upon successful completion, the atan2f, atan2l, and atan2 subroutines return the arc tangent of y/x in the range [-pi, pi] radians.

If y is 0 and x is < 0, ±pi is returned.

If y is 0 and x is > 0, 0 is returned.

If y is < 0 and x is 0, -pi/2 is returned.

If y is > 0 and x is 0, pi/2 is returned.

If x is 0, a pole error does not occur.

If either x or y is NaN, a NaN is returned.

If the result underflows, a range error may occur and y/x is returned.

If y is 0 and x is -0, ±x is returned.

If y is 0 and x is +0, 0 is returned.

For finite values of ±y >0, if x is -Inf, ±x is returned.

For finite values of ±y >0, if x is +Inf, 0 is returned.

For finite values of x, if y is ±Inf, ±x/2 is returned.

If y is ±Inf and x is -Inf, ±3pi/4 is returned.

If y is ±Inf and x is +Inf, ±pi/4 is returned.

If both arguments are 0, a domain error does not occur.

Related Information

math.h in AIX 5L Version 5.2 Files Reference.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]