This is just a short note to give a division trick to go with the multiplication tricks of my previous blog post. Two divisions, r = a / b and s = c / d, can be turned into one division and five multiplies by computing the terms as
t = 1 / (b * d)
r = a * d * t
s = b * c * t
Obviously this is susceptible to various gotchas, such as b or d being zero, loss of precision, et cetera, but it’s still a cool old-school trick that has applications even to this day (as divisions are still more expensive than multiplications and often don’t pipeline well).
1 thought on “And an old-school division trick”
Leave a Reply
You must be logged in to post a comment.
That’s actually a pretty useful trick and its surprising how many people haven’t heard about it. I learned it many years ago at Michael Herf’s site:
http://www.stereopsis.com/2div.html
There you can also find other interesting old-school tricks.