/* @(#)e_atan2.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#include <LibConfig.h>
#include <sys/EfiCdefs.h>
#endif
#if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */
// unary minus operator applied to unsigned type, result still unsigned
#endif
/* __ieee754_atan2(y,x)
* Method :
* 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
* 2. Reduce x to positive by (if x and y are unexceptional):
* ARG (x+iy) = arctan(y/x) ... if x > 0,
* ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0,
*
* Special cases:
*
* ATAN2((anything), NaN ) is NaN;
* ATAN2(NAN , (anything) ) is NaN;
* ATAN2(+-0, +(anything but NaN)) is +-0 ;
* ATAN2(+-0, -(anything but NaN)) is +-pi ;
* ATAN2(+-(anything but 0 and NaN), 0) is +-pi/2;
* ATAN2(+-(anything but INF and NaN), +INF) is +-0 ;
* ATAN2(+-(anything but INF and NaN), -INF) is +-pi;
* ATAN2(+-INF,+INF ) is +-pi/4 ;
* ATAN2(+-INF,-INF ) is +-3pi/4;
* ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2;
*
* Constants:
* The hexadecimal values are the intended ones for the following
* constants. The decimal values may be used, provided that the
* compiler will convert from decimal to binary accurately enough
* to produce the hexadecimal values shown.
*/
#include "math.h"
#include "math_private.h"
static const double
double
__ieee754_atan2(double y, double x)
{
double z;
return x+y;
/* when y = 0 */
switch(m) {
case 0:
case 1: return y; /* atan(+-0,+anything)=+-0 */
}
}
/* when x = 0 */
/* when x is INF */
if(ix==0x7ff00000) {
if(iy==0x7ff00000) {
switch(m) {
}
} else {
switch(m) {
case 0: return zero ; /* atan(+...,+INF) */
}
}
}
/* when y is INF */
/* compute y/x */
switch (m) {
case 0: return z ; /* atan(+,+) */
case 1: {
GET_HIGH_WORD(zh,z);
}
return z ; /* atan(-,+) */
default: /* case 3 */
}
}