about summary refs log tree commit diff
path: root/src/math/hypot.c
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2012-11-13 21:54:32 +0100
committerSzabolcs Nagy <nsz@port70.net>2012-11-13 21:54:32 +0100
commit529a8de46cbf6cce525ab25c4532822006502f29 (patch)
tree96eb7a3856ad9280f1b308d67069580ff55d558a /src/math/hypot.c
parent6d3f1a39c14b12026df84f386875b094e3652990 (diff)
downloadmusl-529a8de46cbf6cce525ab25c4532822006502f29.tar.gz
musl-529a8de46cbf6cce525ab25c4532822006502f29.tar.xz
musl-529a8de46cbf6cce525ab25c4532822006502f29.zip
math: simplify hypot and hypotf using scalbn
this also fixes overflow/underflow raising and excess
precision issues (as those are handled well in scalbn)
Diffstat (limited to 'src/math/hypot.c')
-rw-r--r--src/math/hypot.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/math/hypot.c b/src/math/hypot.c
index ba4c7575..9a4cbdb3 100644
--- a/src/math/hypot.c
+++ b/src/math/hypot.c
@@ -117,12 +117,7 @@ double hypot(double x, double y)
 		t2 = a - t1;
 		w  = sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b)));
 	}
-	if (k != 0) {
-		uint32_t high;
-		t1 = 1.0;
-		GET_HIGH_WORD(high, t1);
-		SET_HIGH_WORD(t1, high+(k<<20));
-		return t1*w;
-	}
+	if (k)
+		w = scalbn(w, k);
 	return w;
 }