1 /* 2 * @(#)zabs.c 5.2 11/03/86 3 */ 4 5 #ifdef tahoe 6 /* THIS IS BASED ON TAHOE FP REPRESENTATION */ 7 #include <tahoemath/FP.h> 8 9 double zabs(real, imag) 10 double real, imag; 11 { 12 double temp, sqrt(); 13 14 if(real < 0) 15 *(long int *)&real ^= SIGN_BIT; 16 if(imag < 0) 17 *(long int *)&imag ^= SIGN_BIT; 18 if(imag > real){ 19 temp = real; 20 real = imag; 21 imag = temp; 22 } 23 if(imag == 0.) /* if((real+imag) == real) */ 24 return(real); 25 26 temp = imag/real; 27 temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/ 28 return(temp); 29 } 30 #endif tahoe 31