e_atan2.c (181074) | e_atan2.c (181204) |
---|---|
1 2/* @(#)e_atan2.c 1.3 95/01/18 */ 3/* 4 * ==================================================== 5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 6 * 7 * Developed at SunSoft, 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 * ==================================================== 12 * 13 */ 14 15#include <sys/cdefs.h> | 1 2/* @(#)e_atan2.c 1.3 95/01/18 */ 3/* 4 * ==================================================== 5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 6 * 7 * Developed at SunSoft, 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 * ==================================================== 12 * 13 */ 14 15#include <sys/cdefs.h> |
16__FBSDID("$FreeBSD: head/lib/msun/src/e_atan2.c 181074 2008-07-31 22:41:26Z das $"); | 16__FBSDID("$FreeBSD: head/lib/msun/src/e_atan2.c 181204 2008-08-02 19:17:00Z das $"); |
17 18/* __ieee754_atan2(y,x) 19 * Method : 20 * 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x). 21 * 2. Reduce x to positive by (if x and y are unexceptional): 22 * ARG (x+iy) = arctan(y/x) ... if x > 0, 23 * ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0, 24 * --- 79 unchanged lines hidden (view full) --- 104 } 105 } 106 } 107 /* when y is INF */ 108 if(iy==0x7ff00000) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny; 109 110 /* compute y/x */ 111 k = (iy-ix)>>20; | 17 18/* __ieee754_atan2(y,x) 19 * Method : 20 * 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x). 21 * 2. Reduce x to positive by (if x and y are unexceptional): 22 * ARG (x+iy) = arctan(y/x) ... if x > 0, 23 * ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0, 24 * --- 79 unchanged lines hidden (view full) --- 104 } 105 } 106 } 107 /* when y is INF */ 108 if(iy==0x7ff00000) return (hy<0)? -pi_o_2-tiny: pi_o_2+tiny; 109 110 /* compute y/x */ 111 k = (iy-ix)>>20; |
112 if(k > 60) z=pi_o_2+0.5*pi_lo; /* |y/x| > 2**60 */ 113 else if(hx<0&&k<-60) z=0.0; /* |y|/x < -2**60 */ | 112 if(k > 60) { /* |y/x| > 2**60 */ 113 z=pi_o_2+0.5*pi_lo; 114 m&=1; 115 } 116 else if(hx<0&&k<-60) z=0.0; /* 0 > |y|/x > -2**-60 */ |
114 else z=atan(fabs(y/x)); /* safe to do y/x */ 115 switch (m) { 116 case 0: return z ; /* atan(+,+) */ | 117 else z=atan(fabs(y/x)); /* safe to do y/x */ 118 switch (m) { 119 case 0: return z ; /* atan(+,+) */ |
117 case 1: { 118 u_int32_t zh; 119 GET_HIGH_WORD(zh,z); 120 SET_HIGH_WORD(z,zh ^ 0x80000000); 121 } 122 return z ; /* atan(-,+) */ | 120 case 1: return -z ; /* atan(-,+) */ |
123 case 2: return pi-(z-pi_lo);/* atan(+,-) */ 124 default: /* case 3 */ 125 return (z-pi_lo)-pi;/* atan(-,-) */ 126 } 127} 128 129#if LDBL_MANT_DIG == 53 130__weak_reference(atan2, atan2l); 131#endif | 121 case 2: return pi-(z-pi_lo);/* atan(+,-) */ 122 default: /* case 3 */ 123 return (z-pi_lo)-pi;/* atan(-,-) */ 124 } 125} 126 127#if LDBL_MANT_DIG == 53 128__weak_reference(atan2, atan2l); 129#endif |