You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
347 B
26 lines
347 B
#include <soft.h>
|
|
|
|
/*
|
|
* sqrt(a^2 + b^2)
|
|
* (but carefully)
|
|
*/
|
|
|
|
double hypot(double a, double b)
|
|
{
|
|
double t;
|
|
if(a<0) a = -a;
|
|
if(b<0) b = -b;
|
|
if(a > b) {
|
|
t = a;
|
|
a = b;
|
|
b = t;
|
|
}
|
|
if(b==0) return(0.);
|
|
a /= b;
|
|
/*
|
|
* pathological overflow possible
|
|
* in the next line.
|
|
*/
|
|
return(b*sqrt(1. + a*a));
|
|
}
|