From 42ae62d757f9d381262c3de05566534ea7f6b6b8 Mon Sep 17 00:00:00 2001 From: Vesa V Date: Sun, 30 Nov 2014 02:22:23 +0200 Subject: [PATCH] Update lmms_math.h fix fastSqrt --- include/lmms_math.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/lmms_math.h b/include/lmms_math.h index b6cc24362..7df7e3e34 100644 --- a/include/lmms_math.h +++ b/include/lmms_math.h @@ -231,9 +231,14 @@ static inline float sqrt_neg( float val ) // fast approximation of square root float fastSqrt( float n ) { - int i = *(int*) &n; - i = ( i + ( 127 << 23 ) ) >> 1; - return *(float*) &i; + union + { + int i; + float f; + } u; + u.f = n; + u.i = ( u.i + ( 127 << 23 ) ) >> 1; + return u.f; }