Why 23, 17, and 26? The Magic Numbers Behind Xorshift Randomness
Xorshift Generators

This deep dive into xorshift generators, the algorithm behind countless games and simulations, explores why specific shift values like 13, 17, and 5 are special. It explains how these three lines of code can generate over four billion unique numbers, the concept of maximal triplets, and why some shift combinations fail. The article also corrects errors in Marsaglia's original paper and discusses variants and canonical triplets.
These constants might be arbitrary, but they’re never random.
- AlanZucconi
I'm really curious... How did you manage to post this link before I did?
- delduca
I’ve replaced Lua’s random by this. I’ve posted about it here https://nullonerror.org/2025/08/02/replacing-lua-s-math-rand...
- saithound
Ah yes, Xorshift, the RANDU [1] of the 21st century [2].
There is no real use case for better non-CS generators, as explained by adrian_b back in 2021 [3].
[1] https://en.wikipedia.org/wiki/RANDU
- smusamashah
> No multiplications. No divisions. No lookup tables. Just a few bitwise instructions.
Would have appreciated this article more if it was written by a human.