1 /*- 2 * Copyright (c) 1980 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)zabs.c 5.3 (Berkeley) 04/12/91"; 10 #endif /* not lint */ 11 12 #ifdef tahoe 13 /* THIS IS BASED ON TAHOE FP REPRESENTATION */ 14 #include <tahoemath/FP.h> 15 16 double zabs(real, imag) 17 double real, imag; 18 { 19 double temp, sqrt(); 20 21 if(real < 0) 22 *(long int *)&real ^= SIGN_BIT; 23 if(imag < 0) 24 *(long int *)&imag ^= SIGN_BIT; 25 if(imag > real){ 26 temp = real; 27 real = imag; 28 imag = temp; 29 } 30 if(imag == 0.) /* if((real+imag) == real) */ 31 return(real); 32 33 temp = imag/real; 34 temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/ 35 return(temp); 36 } 37 #endif tahoe 38