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
| Submitted | Title on HN | Points | Comments |
|---|---|---|---|
| Feb 8, 2019 | Faster remainders when the divisor is a constant: beating compilers & libdivide by matt_d | 197 | 32 |
| Dec 8, 2021 | Faster remainders when divisor is a constant: beating compilers and libdivide by marcodiego | 101 | 16 |
Cited in comments
Linked from 3 Hacker News comments by 3 different people, from Jun 2020 to Apr 2026.
Most recent:
- purplesyringa · Apr 13, 2026
- sgarland · Mar 1, 2023
- im3w1l-alt · Jun 27, 2020