News for hackers. Stuff that matters.
Re:Reciprocal Approximation with 1 Subtraction by mbitsnbites on Monday December 30, 2024 @06:36AM (#42548431)
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);
Re:Reciprocal Approximation with 1 Subtraction by magicalhippo on Monday December 30, 2024 @06:52AM (#42548505)
It's a neat trick, and could be very useful on microcontrollers which doesn't have hardware division but does have hardware multiplication.
Re:Reciprocal Approximation with 1 Subtraction by actionfromafar on Tuesday December 31, 2024 @08:42AM (#42558637)
Hm, like 68000?
Re:Reciprocal Approximation with 1 Subtraction by pechay on Tuesday December 31, 2024 @06:02PM (#42562518)
The 68k has both signed and unsigned 32/16 bit divide instructions.