Fast square root function?

Posts 1–4 of 4 · Page 1 of 1
Fast square root function?
I heard the standard sqrt function from math.h demands a lot of resources. So I ask does anyone know a faster square root function? Currently, I am using a FastSqrt function from the source sdk which is used to calculate the distance from player origin to enemy origin.
Code:
static inline float FastSqrt(float x)
{
	__m128 root = _mm_sqrt_ss(_mm_load_ss(&x));
	return *(reinterpret_cast<float *>(&root));
}


Yes, I'm shit at maths and sorry for copy pasting.
Quote Originally Posted by 4773n0x View Post
I heard the standard sqrt function from math.h demands a lot of resources. So I ask does anyone know a faster square root function? Currently, I am using a FastSqrt function from the source sdk which is used to calculate the distance from player origin to enemy origin.
Code:
static inline float FastSqrt(float x)
{
	__m128 root = _mm_sqrt_ss(_mm_load_ss(&x));
	return *(reinterpret_cast<float *>(&root));
}


Yes, I'm shit at maths and sorry for copy pasting.
Write your own square root function, with minimal lib calls if possible. Just google it out.
Thanks for the answer, thread can be closed now! And sorry for this silly question.
/Solved & closed.
Posts 1–4 of 4 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us