From 1421631f26982b3046c2c48258358c5f76305d1e Mon Sep 17 00:00:00 2001 From: Vesa V Date: Sat, 29 Nov 2014 23:22:39 +0200 Subject: [PATCH] Update lmms_math.h add fast sqrt method --- include/lmms_math.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/lmms_math.h b/include/lmms_math.h index f65670a91..64e4f57ec 100644 --- a/include/lmms_math.h +++ b/include/lmms_math.h @@ -228,4 +228,13 @@ static inline float sqrt_neg( float val ) } +// fast approximation of square root +float fastSqrt( float n ) +{ + int i = *(int*) &n; + i = ( ( i - ( 1 << 23 ) ) >> 1 ) + ( 1 << 29 ); + return *(float*) &i; +} + + #endif