summary refs log tree commit diff
path: root/src/Maths.cpp
blob: 58e769aa0d5bf49b96666528c58ee2b1e93729e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**> HEADER FILES <**/
#include "Maths.h"

double fast_sqrt (register double arg)
{	
#ifdef OS9 
	// 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;
#else
	return sqrt(arg);
#endif
}