e_atan2.c (8870) | e_atan2.c (17141) |
---|---|
1/* @(#)e_atan2.c 5.1 93/09/24 */ 2/* 3 * ==================================================== 4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 * 6 * Developed at SunPro, a Sun Microsystems, Inc. business. 7 * Permission to use, copy, modify, and distribute this 8 * software is freely granted, provided that this notice 9 * is preserved. 10 * ==================================================== 11 */ 12 13#ifndef lint | 1/* @(#)e_atan2.c 5.1 93/09/24 */ 2/* 3 * ==================================================== 4 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 * 6 * Developed at SunPro, a Sun Microsystems, Inc. business. 7 * Permission to use, copy, modify, and distribute this 8 * software is freely granted, provided that this notice 9 * is preserved. 10 * ==================================================== 11 */ 12 13#ifndef lint |
14static char rcsid[] = "$Id: e_atan2.c,v 1.1.1.1 1994/08/19 09:39:43 jkh Exp $"; | 14static char rcsid[] = "$Id: e_atan2.c,v 1.2 1995/05/30 05:47:57 rgrimes Exp $"; |
15#endif 16 17/* __ieee754_atan2(y,x) 18 * Method : 19 * 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x). 20 * 2. Reduce x to positive by (if x and y are unexceptional): 21 * ARG (x+iy) = arctan(y/x) ... if x > 0, 22 * ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0, --- 46 unchanged lines hidden (view full) --- 69 70 EXTRACT_WORDS(hx,lx,x); 71 ix = hx&0x7fffffff; 72 EXTRACT_WORDS(hy,ly,y); 73 iy = hy&0x7fffffff; 74 if(((ix|((lx|-lx)>>31))>0x7ff00000)|| 75 ((iy|((ly|-ly)>>31))>0x7ff00000)) /* x or y is NaN */ 76 return x+y; | 15#endif 16 17/* __ieee754_atan2(y,x) 18 * Method : 19 * 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x). 20 * 2. Reduce x to positive by (if x and y are unexceptional): 21 * ARG (x+iy) = arctan(y/x) ... if x > 0, 22 * ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0, --- 46 unchanged lines hidden (view full) --- 69 70 EXTRACT_WORDS(hx,lx,x); 71 ix = hx&0x7fffffff; 72 EXTRACT_WORDS(hy,ly,y); 73 iy = hy&0x7fffffff; 74 if(((ix|((lx|-lx)>>31))>0x7ff00000)|| 75 ((iy|((ly|-ly)>>31))>0x7ff00000)) /* x or y is NaN */ 76 return x+y; |
77 if((hx-0x3ff00000|lx)==0) return atan(y); /* x=1.0 */ | 77 if(((hx-0x3ff00000)|lx)==0) return atan(y); /* x=1.0 */ |
78 m = ((hy>>31)&1)|((hx>>30)&2); /* 2*sign(x)+sign(y) */ 79 80 /* when y = 0 */ 81 if((iy|ly)==0) { 82 switch(m) { 83 case 0: 84 case 1: return y; /* atan(+-0,+anything)=+-0 */ 85 case 2: return pi+tiny;/* atan(+0,-anything) = pi */ --- 45 unchanged lines hidden --- | 78 m = ((hy>>31)&1)|((hx>>30)&2); /* 2*sign(x)+sign(y) */ 79 80 /* when y = 0 */ 81 if((iy|ly)==0) { 82 switch(m) { 83 case 0: 84 case 1: return y; /* atan(+-0,+anything)=+-0 */ 85 case 2: return pi+tiny;/* atan(+0,-anything) = pi */ --- 45 unchanged lines hidden --- |