129957Smckusick /* 2*29975Smckusick * @(#)zabs.c 5.2 11/03/86 329957Smckusick */ 429957Smckusick 5*29975Smckusick #ifdef tahoe 629957Smckusick /* THIS IS BASED ON TAHOE FP REPRESENTATION */ 729957Smckusick #include <tahoemath/FP.h> 829957Smckusick 929957Smckusick double zabs(real, imag) 1029957Smckusick double real, imag; 1129957Smckusick { 1229957Smckusick double temp, sqrt(); 1329957Smckusick 1429957Smckusick if(real < 0) 1529957Smckusick *(long int *)&real ^= SIGN_BIT; 1629957Smckusick if(imag < 0) 1729957Smckusick *(long int *)&imag ^= SIGN_BIT; 1829957Smckusick if(imag > real){ 1929957Smckusick temp = real; 2029957Smckusick real = imag; 2129957Smckusick imag = temp; 2229957Smckusick } 2329957Smckusick if(imag == 0.) /* if((real+imag) == real) */ 2429957Smckusick return(real); 2529957Smckusick 2629957Smckusick temp = imag/real; 2729957Smckusick temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/ 2829957Smckusick return(temp); 2929957Smckusick } 30*29975Smckusick #endif tahoe 31