home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / FORTRAN / F2C_SRC.ZIP / F2C / LIBF77 / CABS.C < prev    next >
Encoding:
Text File  |  1991-06-10  |  330 b   |  22 lines

  1. double cabs(real, imag)
  2. double real, imag;
  3. {
  4. double temp, sqrt();
  5.  
  6. if(real < 0)
  7.     real = -real;
  8. if(imag < 0)
  9.     imag = -imag;
  10. if(imag > real){
  11.     temp = real;
  12.     real = imag;
  13.     imag = temp;
  14. }
  15. if((real+imag) == real)
  16.     return(real);
  17.  
  18. temp = imag/real;
  19. temp = real*sqrt(1.0 + temp*temp);  /*overflow!!*/
  20. return(temp);
  21. }
  22.