TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Fast division by multiplication

66 pointsby kinetikover 15 years ago

5 comments

unwindover 15 years ago
Stuff like this is what I think of when I hear "compiler writers are smarter than you, don't micro-optimize".<p>It's amazingly much better to have the compiler hide this, than for application-level programmers to figure out the trick by themselves, and obfuscate their code accordingly. Sweet.
pmjordanover 15 years ago
An oldie but goodie. In practice, compilers are pretty good at working this out for you, <i>provided the denominator is a constant expression.</i> In other words, if you're burning cycles because of a division with variable but rarely-changing denominator in an inner loop, it can make sense to precompute the equivalent multiplication factor and perform the multiplication explicitly.
arnorhsover 15 years ago
I wish I could understand that. The math and all. If I could, I would be such an awesome programmer.<p>And incredibly smart.<p>Hat's off for this guy at least.
评论 #1131391 未加载
评论 #1132323 未加载
drallisonover 15 years ago
The article is not available at the moment so I am flying a bit blind here.<p>H. Warren, Hackers Delight has a nice discussion of this problem. One of my favorite books, but I like to do code generators.<p><a href="http://www.amazon.com/Hackers-Delight-Henry-S-Warren/dp/0201914654/ref=sr_1_1?ie=UTF8&#38;s=books&#38;qid=1266426413&#38;sr=8-1" rel="nofollow">http://www.amazon.com/Hackers-Delight-Henry-S-Warren/dp/0201...</a>
lemmingover 15 years ago
As an aside, Ridiculous Fish, apart from the excellent name, is one of the best blogs I know - interesting topics, good scientific method proving his conclusions, and a great writing style. I wish he posted more.
评论 #1131512 未加载