* config/rs6000/rs6000.c (rs6000_return_in_memory): Allow Altivec
[official-gcc.git] / libjava / java / lang / w_atan2.c
blob91742c72b91d5a095d000fc3f5241d4126518de1
2 /* @(#)w_atan2.c 5.1 93/09/24 */
3 /*
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 * Developed at SunPro, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
10 * is preserved.
11 * ====================================================
16 FUNCTION
17 <<atan2>>, <<atan2f>>---arc tangent of y/x
19 INDEX
20 atan2
21 INDEX
22 atan2f
24 ANSI_SYNOPSIS
25 #include <math.h>
26 double atan2(double <[y]>,double <[x]>);
27 float atan2f(float <[y]>,float <[x]>);
29 TRAD_SYNOPSIS
30 #include <math.h>
31 double atan2(<[y]>,<[x]>);
32 double <[y]>;
33 double <[x]>;
35 float atan2f(<[y]>,<[x]>);
36 float <[y]>;
37 float <[x]>;
39 DESCRIPTION
41 <<atan2>> computes the inverse tangent (arc tangent) of <[y]>/<[x]>.
42 <<atan2>> produces the correct result even for angles near
43 @ifinfo
44 pi/2 or -pi/2
45 @end ifinfo
46 @tex
47 $\pi/2$ or $-\pi/2$
48 @end tex
49 (that is, when <[x]> is near 0).
51 <<atan2f>> is identical to <<atan2>>, save that it takes and returns
52 <<float>>.
54 RETURNS
55 <<atan2>> and <<atan2f>> return a value in radians, in the range of
56 @ifinfo
57 -pi to pi.
58 @end ifinfo
59 @tex
60 $-\pi$ to $\pi$.
61 @end tex
63 If both <[x]> and <[y]> are 0.0, <<atan2>> causes a <<DOMAIN>> error.
65 You can modify error handling for these functions using <<matherr>>.
67 PORTABILITY
68 <<atan2>> is ANSI C. <<atan2f>> is an extension.
73 /*
74 * wrapper atan2(y,x)
77 #include "fdlibm.h"
78 #include <errno.h>
80 #ifndef _DOUBLE_IS_32BITS
82 #ifdef __STDC__
83 double atan2(double y, double x) /* wrapper atan2 */
84 #else
85 double atan2(y,x) /* wrapper atan2 */
86 double y,x;
87 #endif
89 #ifdef _IEEE_LIBM
90 return __ieee754_atan2(y,x);
91 #else
92 double z;
93 struct exception exc;
94 z = __ieee754_atan2(y,x);
95 if(_LIB_VERSION == _IEEE_||isnan(x)||isnan(y)) return z;
96 if(x==0.0&&y==0.0) {
97 /* atan2(+-0,+-0) */
98 exc.arg1 = y;
99 exc.arg2 = x;
100 exc.type = DOMAIN;
101 exc.name = "atan2";
102 exc.err = 0;
103 exc.retval = 0.0;
104 if(_LIB_VERSION == _POSIX_)
105 errno = EDOM;
106 else if (!matherr(&exc)) {
107 errno = EDOM;
109 if (exc.err != 0)
110 errno = exc.err;
111 return exc.retval;
112 } else
113 return z;
114 #endif
117 #endif /* defined(_DOUBLE_IS_32BITS) */