Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC Numerics / Part 2 - The PowerPC Numerics C Implementation
Chapter 10 - Transcendental Functions / Trigonometric Functions


atan2

You can use the atan2 function to compute the arc tangent of a real number divided by another real number.

double_t atan2 (double_t y, double_t x);
y
Any floating-point number.
x
Any floating-point number.
DESCRIPTION
The atan2 function returns the arc tangent of its first argument divided by its second argument. The return value is expressed in radians in the range [-\x86, +\x86], using the signs of its operands to determine the quadrant.

atan2(y,x) = arctan(y/x) = z such that tan(z) = y/x

EXCEPTIONS
When x and y are finite and nonzero, the result of atan2(y,x) might raise one of the following exceptions:

  • inexact (if either x or y is any finite, nonzero value)
  • underflow (if the result is inexact and must be represented as a denormalized number or 0)

SPECIAL CASES
Table 10-26 shows the results when one of the arguments to the atan2 function is a zero, a NaN, or an Infinity. In this table, x and y are finite, nonzero floating-point numbers.
Special cases for the atan2 function
OperationResultExceptions raised
atan2(+0,x) +0 x > 0None
 +\x86 x < 0None
atan2(y,+0) +\x86/2 y > 0None
 -\x86/2 y < 0None
atan2(±0,+0) \xB10None
atan2(-0,x) -0 x > 0Inexact
 -\x86 x < 0Inexact
atan2(y,-0) +\x86/2 y > 0None
 -\x86/2 y < 0None
atan2(±0,-0) \xB1\x86Inexact
atan2(NaN,x) NaN[47]None[48]
atan2(y,NaN) NaNNone
atan2(+ ,x) \x86/2Inexact
atan2(y,+ ) \xB10None
atan2(± ,+ ) \xB13\x86/4Inexact
atan2(- ,x) -\x86/2Inexact
atan2(y,- ) \xB1\x86None
atan2(± ,- ) \xB13\x86/4Inexact

EXAMPLES
z = atan2(1.0, 1.0); /* z = arctan 1/1 = arctan 1 = \x86/4. The 
                        inexact exception is raised. */
z = atan2(3.5, 0.0); /* z = arctan 3.5/0 = arctan    = \x86/2 */

[47] If both arguments are NaNs, it is undefined which one atan2 returns.
[48] If the NaN is a signaling NaN, the invalid exception is raised.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996