* io.c (rb_open_file): encoding in mode string was ignored if perm is
[ruby-svn.git] / missing / hypot.c
blob5a663553cfc9117ddcf068ea0d745c943739ca33
1 /* public domain rewrite of hypot */
3 #include <math.h>
5 double hypot(double x, double y)
7 if (x < 0) x = -x;
8 if (y < 0) y = -y;
9 if (x < y) {
10 double tmp = x;
11 x = y; y = tmp;
13 if (y == 0.0) return x;
14 y /= x;
15 return x * sqrt(1.0+y*y);