Hacker News .hn
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
im3w1l
on Feb 21, 2017
|
parent
|
context
|
favorite
| on:
How do compilers optimize divisions?
And for even divisors you can separate the divisor into a power of two, and an odd part. The odd part is checked as before, and the power of two is checked with an
and mask
.
raphlinus
on Feb 21, 2017
[–]
An even trickier way to do this is to rotate right by the power of two factor between doing the multiply and the compare.
im3w1l
on Feb 23, 2017
|
parent
[–]
That wouldn't work, because a number that is bigger than the threshold could become smaller than it after the rotation.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: