blob: f8f26649b5eec29df30e10629fc81d7ef90d1e9d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
/**> HEADER FILES <**/
#include "Maths.h"
double fast_sqrt (register double arg)
{
// Can replace with slower return std::sqrt(arg);
register double result;
if (arg == 0.0) return 0.0;
asm {
frsqrte result,arg // Calculate Square root
}
// Newton Rhapson iterations.
result = result + 0.5 * result * (1.0 - arg * result * result);
result = result + 0.5 * result * (1.0 - arg * result * result);
return result * arg;
}
|