On Fri, 2013-06-07 at 18:53 +1000, Benjamin Herrenschmidt wrote: > + > +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 :-) Cheers, Ben. _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev