Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ atan2d(3M) — HP-UX ANSI C A.09.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

trig(3M)

isinf(3M)

isnan(3M)

matherr(3M)

trigd(3M)

NAME

sind(), cosd(), tand(), asind(), acosd(), atand(), atan2d(), sindf(), cosdf(), tandf(), asindf(), acosdf(), atandf(), atan2df() − degree-valued trigonometric functions

SYNOPSIS

#include <math.h>

double sind(double x);

double cosd(double x);

double tand(double x);

double asind(double x);

double acosd(double x);

double atand(double x);

double atan2d(double y, double x);

float sindf(float x);

float cosdf(float x);

float tandf(float x);

float asindf(float x);

float acosdf(float x);

float atandf(float x);

float atan2df(float y, float x);

DESCRIPTION

sind(), cosd(), tand(), asind(), acosd(), atand(), and atan2d() are degree-valued versions of the trigonometric functions.  The functions return the values indicated:

sind() sine of x (x specified in degrees)

cos() cosine of x (x specified in degrees)

tand() tangent of x (x specified in degrees)

asind() arcsine of x in the range −90 to 90. 

acosd() arccosine of x in the range 0 to 180. 

atand() arctangent of x in the range −90 to 90.  If x is ±INFINITY , atand() returns ±90 respectively. 

atan2d() arctangent of y/x, in the range −180 to 180, using the signs of both arguments to determine the quadrant of the return value.

Other atan2d() returns:

• 45 when y and x are +INFINITY. 

• 135 when y is +INFINITY and x is −INFINITY. 

• −45 when y is −INFINITY and x is +INFINITY. 

• −135 when y and x are −INFINITY. 

• 0.0 when y is 0.0 and x is a positive number. 

• 180 when y is 0.0 and x is a negative number, or −180 when y is -0.0 and x is a negative number. 

• 90 when y is a positive number and x is 0.0, or −90 when y is a negative number and x is 0.0. 

• ±90 if y/x would overflow.  The result will be 90 if y is a positive number and −90 if y is a negative number. 

• ±180 or 0.0 if y/x would underflow.  The result will be 0.0 if x is a positive number, 180 if x is a negative number and y is a positive number, and −180 if x and y are both negative numbers. 

sindf(), cosdf(), tandf(), asindf(), cosdf(), atandf(), and atan2df() are float versions of these functions; they take float arguments and return float results.  They are named in accordance with the conventions specified in the "Future Library Directions" section of the ANSI C standard.  Their performance is significantly faster than that of the double versions of the functions.  Compiling must be done in ANSI mode (use the -Aa option) in order to use these functions; otherwise, the compiler promotes the float arguments to double, and the functions return incorrect results. 

DEPENDENCIES

Series 300/400

These functions are not supported on the Series 300/400. 

Series 700/800

These functions are provided in the PA1.1 versions of the math library only.  The +DA1.1 option (the default on Series 700 systems) links in a PA1.1 version automatically.  A PA1.1 library can be linked in explicitly.  For more information, see the HP-UX Floating-Point Guide.

ERRORS

/lib/libm.a

sind(), cosd(), and tand() lose accuracy when their argument is far from zero.  For arguments sufficiently large, these functions return 0 when there would otherwise be a complete loss of significance.  In this case a message indicating TLOSS error is printed on the standard error output.  For less extreme arguments causing partial loss of significance, a PLOSS error is generated but no message is printed.  In both cases, errno is set to ERANGE. 

If the magnitude of the argument of asind() or acosd() is greater than one, or if both arguments of atan2d() are 0.0, 0 is returned and errno is set to EDOM.  In addition, a message indicating DOMAIN error is printed on the standard error output. 

sind(), cosd(), tand(), acosd(), and asind() return NaN and set errno to EDOM when x is NaN or ±INFINITY.  In addition, a message indicating DOMAIN error is printed on the standard error output. 

atand() returns NaN and sets errno to EDOM when x is NaN.  In addition, a message indicating DOMAIN error is printed on the standard error output. 

atan2d() returns NaN and sets errno to EDOM when x or y is NaN.  In addition, a message indicating DOMAIN error is printed on the standard error output. 

These error-handling procedures can be changed with the matherr() function (see matherr(3M)).

/lib/libM.a

No error messages are printed on the standard error output. 

sind(), cosd(), and tand() lose accuracy when their argument is far from zero.  For arguments sufficiently large, these functions return 0 when there would otherwise be a complete loss of significance.  For less extreme arguments causing partial loss of significance, a PLOSS error is generated.  In both cases, errno is set to ERANGE. 

If the magnitude of the argument of asind() or acosd() is greater than one, NaN is returned and errno is set to EDOM. 

If both arguments of atan2d() are 0.0, 0 is returned and errno is set to EDOM. 

sind(), cosd(), tand(), acosd(), and asind() return NaN and set errno to EDOM when x is NaN or ±INFINITY. 

atand() returns NaN and sets errno to EDOM when x is NaN. 

atan2d() returns NaN and sets errno to EDOM when x or y is NaN. 

These error-handling procedures can be changed with the function _matherr() (see matherr(3M)). Note that _matherr() is provided in order to assist in migrating programs from libm.a to libM.a and is not a part of XPG3, ANSI C, or POSIX. 

SEE ALSO

trig(3M), isinf(3M), isnan(3M), matherr(3M). 

Hewlett-Packard Company  —  HP-UX Release 9.0: August 1992

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026