Hacker News new | ask | show | jobs
by mbitsnbites 529 days ago
Yep. Along the same lines. This one is even simpler, though, as it requires only a single integer CPU instruction (and the simplest of all instructions too).

If you want full precision, you need to do three Newton-Raphson iterations after the initial approximation. One iteration is:

    y = y * (2.0F - x * y);
1 comments

It's a neat trick, and could be very useful on microcontrollers which doesn't have hardware division but does have hardware multiplication.
Hm, like 68000?
The 68k has both signed and unsigned 32/16 bit divide instructions.