summaryrefslogtreecommitdiff
path: root/missing/hypot.c
diff options
context:
space:
mode:
Diffstat (limited to 'missing/hypot.c')
-rw-r--r--missing/hypot.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/missing/hypot.c b/missing/hypot.c
new file mode 100644
index 0000000..aad5259
--- /dev/null
+++ b/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);
+}