00001 /* public domain rewrite of hypot */ 00002 00003 #include <math.h> 00004 00005 double hypot(double x, double y) 00006 { 00007 if (x < 0) x = -x; 00008 if (y < 0) y = -y; 00009 if (x < y) { 00010 double tmp = x; 00011 x = y; y = tmp; 00012 } 00013 if (y == 0.0) return x; 00014 y /= x; 00015 return x * sqrt(1.0+y*y); 00016 } 00017