From 529a8de46cbf6cce525ab25c4532822006502f29 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Tue, 13 Nov 2012 21:54:32 +0100 Subject: math: simplify hypot and hypotf using scalbn this also fixes overflow/underflow raising and excess precision issues (as those are handled well in scalbn) --- src/math/hypotf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/math/hypotf.c') diff --git a/src/math/hypotf.c b/src/math/hypotf.c index 9fd77e6a..4d80178d 100644 --- a/src/math/hypotf.c +++ b/src/math/hypotf.c @@ -80,9 +80,7 @@ float hypotf(float x, float y) t2 = a - t1; w = sqrtf(t1*y1-(w*(-w)-(t1*y2+t2*b))); } - if (k != 0) { - SET_FLOAT_WORD(t1, 0x3f800000+(k<<23)); - return t1*w; - } + if (k) + w = scalbnf(w, k); return w; } -- cgit v1.2.1