Pianoman wrote 17 lines
Once upon a time, I did this in single precision:
1) I made a crude 1st guess by manufacturing, in
Assembler, a linear fit mantissa - 2 different fits depending if exponent was odd or even - and the
appropriate exponent. The worst case error of this is easily calculated. Process takes 2 floating ops and some integer stuff taking out and putting back the exponent.
2) I then explicitly coded the iterations required to converge in this worst case: just 3 floating ops per (or is it 2 plus integer exponent manipulation?)
and it didn't take very many. No test. Saving the test saved more time than was wasted doing unnecessary
iterations, at least on the machine I did it on. This may not be so in double precision ...
Best of luck.
Andrew Bennett, Avondale Vineyard, Nova Scotia.
