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

Original title: Xorshift Generators

> Hacker News story 49310128 · language: en · submitted 2026-08-15
> Web version: https://zeli.app/story/49310128
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 44 · by [tobr](<https://news.ycombinator.com/user?id=tobr>) · 💬 31
[original](<https://www.alanzucconi.com/2026/08/15/xorshift-generators/>) · [HN discussion](<https://news.ycombinator.com/item?id=49310128>)

## Summary

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.

## Key quote

> These constants might be arbitrary, but they’re never random.

## HN discussion (31 comments)

### [AlanZucconi](<https://news.ycombinator.com/item?id=49311842>)

> I'm really curious... How did you manage to post this link before I did?

### [delduca](<https://news.ycombinator.com/item?id=49311059>)

> 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](<https://news.ycombinator.com/item?id=49311548>)

> 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
>
> [2] https://arxiv.org/abs/1908.10020
>
> [3] https://news.ycombinator.com/item?id=28886698

### [smusamashah](<https://news.ycombinator.com/item?id=49312864>)

> \> 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.

---

## Cite

- Page: https://zeli.app/story/49310128
- Date: 2026-08-15
- Source: alanzucconi.com (https://www.alanzucconi.com/2026/08/15/xorshift-generators/)
- Hacker News: https://news.ycombinator.com/item?id=49310128

## Other languages

- zh: https://zeli.app/zh/story/49310128 · markdown: https://zeli.app/zh/story/49310128.md
- ja: https://zeli.app/ja/story/49310128 · markdown: https://zeli.app/ja/story/49310128.md
- ko: https://zeli.app/ko/story/49310128 · markdown: https://zeli.app/ko/story/49310128.md
- de: https://zeli.app/de/story/49310128 · markdown: https://zeli.app/de/story/49310128.md
- es: https://zeli.app/es/story/49310128 · markdown: https://zeli.app/es/story/49310128.md
