lua-users home
lua-l archive

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




On Thu, Mar 22, 2018 at 11:57 AM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> You're currently using one modulo operation in the simple case, which on my
> desktop processor (older Core i5) takes longer than a division.

I guess most processors (including i5) use the same instruction to
compute a modulo and a division, so they have exactly the same cost.



That test was on a 32-bit Linux platform, where you have a 64/32 divide instruction only. For 64-bit x86 machines it's the same instruction.

Sorry about getting confused about the sequence. Regular linear congruential generators produce an even-odd-even-odd pattern, so a 128 bit sequence sounded reasonable. xorshift128 and its variants are not nearly that bad, but there still a relatively simple linear relationship there. If you're using it for running a game it probably does not matter, if you're running a casino it definitely does.