Search found 1 match

by stavrosd
Sun Dec 08, 2019 1:55 am
Forum: Hardware
Topic: Integer division performance ????
Replies: 25
Views: 22551

Re: Integer division performance ????

If you want to divide a positive integer by a power of 2, right sifting is faster than division.
In most architectures the shift command requires only one CPU clock.
4096 = 2^12
Instead of "X/4096", try "X>>12"
https://en.wikipedia.org/wiki/Arithmetic_shift