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