fsqrt
David Laight
David.Laight at ACULAB.COM
Fri Jun 7 20:48:53 EST 2013
> > +
> > +static double crackpot_sqrt(double val)
> > +{
> > + int i;
> > + float x, y;
> > + const float f = 1.5F;
> > +
> > + x = val * 0.5F;
> > + y = val;
> > + i = * ( int * ) &y;
> > + i = 0x5f3759df - ( i >> 1 );
> > + y = * ( float * ) &i;
> > + y = y * ( f - ( x * y * y ) );
> > + y = y * ( f - ( x * y * y ) );
> > + return val * y;
> > +}
> > +
>
> For those interested, this is the Quake3 sqrt from Carmack ... there's
> plenty of literature about it one or two google clicks away :-)
I guess that is a rough enough approximation for graphics.
However it will be miscompiled unless i and y are put in a union.
David
More information about the Linuxppc-dev
mailing list