Daniel Lemire personal blog

Faster remainders when the divisor is a constant: beating compilers & libdivide

Not all instructions on modern processors cost the same. Additions and subtractions are cheaper than multiplications which are themselves cheaper than divisions. For this reason, compilers frequently replace division instructions by multiplications. Roughly speaking, it works in this manner. Suppose that you want to…
Points
197
HN comments
48
Submissions
2
Cited by
3 commenters

Math & AlgorithmsSystems & Performance2019

On Hacker News

SubmittedTitle on HNPointsComments
Feb 8, 2019Faster remainders when the divisor is a constant: beating compilers & libdivide by matt_d19732
Dec 8, 2021Faster remainders when divisor is a constant: beating compilers and libdivide by marcodiego10116

Cited in comments

Linked from 3 Hacker News comments by 3 different people, from Jun 2020 to Apr 2026.

Most recent:

Search every comment that links here →

More from Daniel Lemire

All 87 posts →

Related posts from the same era