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:

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • LinkedIn

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:

    http://www.stereopsis.com/2div.html

    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.