summaryrefslogtreecommitdiff
path: root/trunk/missing/hypot.c
diff options
context:
space:
mode:
Diffstat (limited to 'trunk/missing/hypot.c')
-rw-r--r--trunk/missing/hypot.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/trunk/missing/hypot.c b/trunk/missing/hypot.c
new file mode 100644
index 0000000000..5a663553cf
--- /dev/null
+++ b/trunk/missing/hypot.c
@@ -0,0 +1,16 @@
+/* public domain rewrite of hypot */
+
+#include <math.h>
+
+double hypot(double x, double 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);
+}