summaryrefslogtreecommitdiff
path: root/ruby_1_8_6/missing/hypot.c
diff options
context:
space:
mode:
Diffstat (limited to 'ruby_1_8_6/missing/hypot.c')
-rw-r--r--ruby_1_8_6/missing/hypot.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/ruby_1_8_6/missing/hypot.c b/ruby_1_8_6/missing/hypot.c
new file mode 100644
index 0000000000..aad5259e92
--- /dev/null
+++ b/ruby_1_8_6/missing/hypot.c
@@ -0,0 +1,17 @@
+/* public domain rewrite of hypot */
+
+#include <math.h>
+
+double hypot(x,y)
+ double x, y;
+{
+ if (x < 0) x = -x;
+ if (y < 0) y = -y;
+ if (x < y) {
+ double tmp = x;
+ x = y; y = tmp;
+ }
+ if (y == 0.0) return x;
+ y /= x;
+ return x * sqrt(1.0+y*y);
+}