tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: A Fast Alternative to Modulo Reduction



On Fri, Dec 16, 2016 at 02:39:05PM +0530, Abhinav Upadhyay wrote:
> I came across an interesting article [1] which talks about a faster
> alternative to the mod operation (x % N) for mapping a number to a
> fixed range, such as [0, N), which is common when we want to generate
> random numbers within a given range, or map a hash value to a range of
> indices in an array.

Old hat. See fast_divide32(3).

Joerg


Home | Main Index | Thread Index | Old Index