mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-16 23:57:54 +01:00
09c656ca68
Obtained from: netlib.att.com
28 lines
427 B
C
28 lines
427 B
C
#ifdef KR_headers
|
|
extern double sqrt();
|
|
double f__cabs(real, imag) double real, imag;
|
|
#else
|
|
#undef abs
|
|
#include "math.h"
|
|
double f__cabs(double real, double imag)
|
|
#endif
|
|
{
|
|
double temp;
|
|
|
|
if(real < 0)
|
|
real = -real;
|
|
if(imag < 0)
|
|
imag = -imag;
|
|
if(imag > real){
|
|
temp = real;
|
|
real = imag;
|
|
imag = temp;
|
|
}
|
|
if((real+imag) == real)
|
|
return(real);
|
|
|
|
temp = imag/real;
|
|
temp = real*sqrt(1.0 + temp*temp); /*overflow!!*/
|
|
return(temp);
|
|
}
|