Merge pull request #438 from gamemasterplc/main
Properly fix sqrtf constants
This commit is contained in:
commit
afb776544c
17 changed files with 29 additions and 32 deletions
|
|
@ -10,17 +10,19 @@
|
|||
#ifdef __MWERKS__
|
||||
extern inline float sqrtf(float x)
|
||||
{
|
||||
volatile float y;
|
||||
if(x > 0.0f)
|
||||
{
|
||||
double guess = __frsqrte((double)x); // returns an approximation to
|
||||
guess = 0.5*guess*(3.0 - guess*guess*x); // now have 12 sig bits
|
||||
guess = 0.5*guess*(3.0 - guess*guess*x); // now have 24 sig bits
|
||||
guess = 0.5*guess*(3.0 - guess*guess*x); // now have 32 sig bits
|
||||
y=(float)(x*guess);
|
||||
return y;
|
||||
}
|
||||
return x;
|
||||
static const double _half = .5;
|
||||
static const double _three = 3.0;
|
||||
volatile float y;
|
||||
if (x > 0.0f)
|
||||
{
|
||||
double guess = __frsqrte((double)x); // returns an approximation to
|
||||
guess = _half*guess*(_three - guess*guess*x); // now have 12 sig bits
|
||||
guess = _half*guess*(_three - guess*guess*x); // now have 24 sig bits
|
||||
guess = _half*guess*(_three - guess*guess*x); // now have 32 sig bits
|
||||
y = (float)(x*guess);
|
||||
return y ;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
#else
|
||||
float sqrtf(float x);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
#ifndef _REL_SQRT_CONSTS
|
||||
#define _REL_SQRT_CONSTS
|
||||
|
||||
const double __fakeHalf = 0.5;
|
||||
const double __fakeThree = 3.0;
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue