prime/include/math_ppc.h
Phillip Stephens a108e76a1f Minor cleanups
Former-commit-id: 5bfa43d591de75cac0f976b59cb0726a4a767e13
2022-07-30 02:12:25 -07:00

23 lines
543 B
C

#ifndef _MATH_PPC_H_
#define _MATH_PPC_H_
inline float sqrtf(float 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 ;
}
#endif