1 /* wf_atan2.c -- float version of w_atan2.c.
2  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3  */
4 
5 /*
6  * ====================================================
7  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8  *
9  * Developed at SunPro, a Sun Microsystems, Inc. business.
10  * Permission to use, copy, modify, and distribute this
11  * software is freely granted, provided that this notice
12  * is preserved.
13  * ====================================================
14  *
15  */
16 
17 /*
18  * wrapper atan2f(y,x)
19  */
20 
21 #include "fdlibm.h"
22 #include <errno.h>
23 
24 #ifdef __STDC__
atan2f(float y,float x)25 	float atan2f(float y, float x)		/* wrapper atan2f */
26 #else
27 	float atan2f(y,x)			/* wrapper atan2 */
28 	float y,x;
29 #endif
30 {
31 #ifdef _IEEE_LIBM
32 	return __ieee754_atan2f(y,x);
33 #else
34 	float z;
35 	struct exception exc;
36 	z = __ieee754_atan2f(y,x);
37 	if(_LIB_VERSION == _IEEE_||isnanf(x)||isnanf(y)) return z;
38 	if(x==(float)0.0&&y==(float)0.0) {
39 	    /* atan2f(+-0,+-0) */
40 	    exc.arg1 = y;
41 	    exc.arg2 = x;
42 	    exc.err = 0;
43 	    exc.type = DOMAIN;
44 	    exc.name = "atan2f";
45 	    exc.retval = 0.0;
46 	    if(_LIB_VERSION == _POSIX_)
47 	       errno = EDOM;
48 	    else if (!matherr(&exc)) {
49 	       errno = EDOM;
50 	    }
51 	    if (exc.err != 0)
52 	       errno = exc.err;
53 	    return (float)exc.retval;
54 	} else
55 	    return z;
56 #endif
57 }
58 
59 #ifdef _DOUBLE_IS_32BITS
60 
61 #ifdef __STDC__
atan2(double y,double x)62 	double atan2(double y, double x)
63 #else
64 	double atan2(y,x)
65 	double y,x;
66 #endif
67 {
68 	return (double) atan2f((float) y, (float) x);
69 }
70 
71 #endif /* defined(_DOUBLE_IS_32BITS) */
72