HPlogo HP-UX Reference Volume 4 of 5 > a

atan2(3M)

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

NAME

atan2(), atan2f() — arctangent-and-quadrant functions

SYNOPSIS

#include <math.h>

double atan2(double y, double x);

float atan2f(float y, float x);

DESCRIPTION

atan2() returns the arctangent of y/x, in the range -π to π, using the signs of both arguments to determine the quadrant of the return value.

atan2f() is a float version of atan2(); it takes float arguments and returns a float result. To use this function, compile either with the default -Ae option or with the -Aa and -D_HPUX_SOURCE options.

atan2f() is not specified by any standard, but it is named in accordance with the conventions specified in the "Future Library Directions" section of the ANSI C standard.

To use these functions, make sure your program includes <math.h>, and link in the math library by specifying -lm on the compiler or linker command line.

Millicode versions of the atan2() function are available. Millicode versions of math library functions are usually faster than their counterparts in the standard library. To use these versions, compile your program with the +Olibcalls or the +Oaggressive optimization option.

For special cases, the millicode versions return the same values as their standard library counterparts (see the RETURN VALUE section).

For more information, see the HP-UX Floating-Point Guide.

RETURN VALUE

If y and x are +INFINITY, atan2() returns π/4.

If y is +INFINITY and x is -INFINITY, atan2() returns 3*π/4.

If y is -INFINITY and x is +INFINITY, atan2() returns -π/4.

If y and x are -INFINITY, atan2() returns -3*π/4.

If y is zero and x is greater than zero, atan2() returns zero.

If y is zero and x is less than zero, atan2() returns π.

If y is -zero and x is less than zero, atan2() returns -π.

If y is greater than zero and x is zero, atan2() returns π/2.

If y is less than zero and x is zero, atan2() returns -π/2.

If y/x would overflow, atan2() returns ±π/2. The result will be π/2 if y is greater than zero and -π/2 if y is less than zero.

If y/x after rounding would be smaller in magnitude than MINDOUBLE, atan2() returns ±π or zero. The result is zero if x is greater than zero, π if x is less than zero and y is greater than zero, and -π if x and y are both less than zero.

If both x and y are zero, atan2() returns NaN.

If x or y is NaN, atan2() returns NaN.

If the correct value after rounding would be smaller in magnitude than MINDOUBLE, atan2() returns zero.

ERRORS

No errors are defined.

STANDARDS CONFORMANCE

atan2(): SVID3, XPG4.2, ANSI C

© Hewlett-Packard Development Company, L.P.