1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 * 6 * @(#)cabs.c 5.1 06/07/85 7 */ 8 9 double cabs(real, imag) 10 double real, imag; 11 { 12 double temp, sqrt(); 13 14 if(real < 0) 15 real = -real; 16 if(imag < 0) 17 imag = -imag; 18 if(imag > real){ 19 temp = real; 20 real = imag; 21 imag = temp; 22 } 23 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