And an old-school division trick

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).

Similar Posts:

Be Sociable, Share!

1 Comment »

  1. icastano said,

    August 16, 2007 @ 7:28 pm

    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:

    There you can also find other interesting old-school tricks.

RSS feed for comments on this post · TrackBack URI

Leave a Comment

You must be logged in to post a comment.