3 ms·
Are you talking about randomly shuffling the bits or getting a new permutation? Any suggestions on how to quickly randomly shuffle the bits of a number?
by XCSme 7y ago
Are you talking about randomly shuffling the bits or getting a new permutation? Any suggestions on how to quickly randomly shuffle the bits of a number?
- richard_todd 7y agoRandomly shuffling the bits _is_ a new permutation (of those bits). There may be a faster way to shuffle the bits of whole bytes/words on some architectures, but for the general case I suspect a normal shuffling algorithm (like Fisher-Yates) and shifts+and+xor swapping is best.
- XCSme 7y agoOh, sorry for not making it clear, when I meant permutation I was referring to the the immediately next permutation. I guess after current set is over you could also take the Xth permutation of the current state, where X is a random integer. (so you randomly skip some permutations to not make it predictable).
- richard_todd 7y agoYeah jumping ahead by X permutations would be good as well.