113618394Sjtc /* @(#)w_atan2.c 5.1 93/09/24 */
213618394Sjtc /*
313618394Sjtc * ====================================================
413618394Sjtc * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
513618394Sjtc *
613618394Sjtc * Developed at SunPro, a Sun Microsystems, Inc. business.
713618394Sjtc * Permission to use, copy, modify, and distribute this
813618394Sjtc * software is freely granted, provided that this notice
913618394Sjtc * is preserved.
1013618394Sjtc * ====================================================
1113618394Sjtc */
1213618394Sjtc
1341f0dee6Slukem #include <sys/cdefs.h>
14d1f06e0bSjtc #if defined(LIBM_SCCS) && !defined(lint)
15*b36bcf93Sdrochner __RCSID("$NetBSD: w_atan2.c,v 1.10 2007/08/10 21:20:36 drochner Exp $");
16bc3f7bf6Sjtc #endif
17bc3f7bf6Sjtc
1813618394Sjtc /*
1913618394Sjtc * wrapper atan2(y,x)
2013618394Sjtc */
2113618394Sjtc
22*b36bcf93Sdrochner #include "namespace.h"
238346e333Sjtc #include "math.h"
248346e333Sjtc #include "math_private.h"
2513618394Sjtc
26*b36bcf93Sdrochner #ifdef __weak_alias
__weak_alias(atan2,_atan2)27*b36bcf93Sdrochner __weak_alias(atan2, _atan2)
28*b36bcf93Sdrochner #endif
2913618394Sjtc
30aa30599eSwiz double
31aa30599eSwiz atan2(double y, double x) /* wrapper atan2 */
3213618394Sjtc {
3313618394Sjtc #ifdef _IEEE_LIBM
3413618394Sjtc return __ieee754_atan2(y,x);
3513618394Sjtc #else
3613618394Sjtc double z;
3713618394Sjtc z = __ieee754_atan2(y,x);
3813618394Sjtc if(_LIB_VERSION == _IEEE_||isnan(x)||isnan(y)) return z;
3913618394Sjtc if(x==0.0&&y==0.0) {
4013618394Sjtc return __kernel_standard(y,x,3); /* atan2(+-0,+-0) */
4113618394Sjtc } else
4213618394Sjtc return z;
4313618394Sjtc #endif
4413618394Sjtc }
45