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; }