Pseudo-Random Numbers (xorshift)

Shifting bits and XOR-ing them produces a stream of numbers that look random.

x ^= x << 13; x ^= x >> 17; x ^= x << 5

The same seed always gives the same sequence. The seed must not be 0.

The 32-bit version has period 2³² − 1. For cryptography or fair lotteries, use a dedicated secure generator.

Calculator

Change a value and the result and picture update instantly.

Result

1st270369
2nd67634700
3rd2.647×10^9
1st scaled to 0–16.295×10^-5

Animated picture

The picture follows your values. Some points and shapes can be dragged.

Use in game development

Because a seed reproduces the same results, it powers daily puzzles, replays and procedural map generation.

Code example (JavaScript)

let x = seed >>> 0 || 1;
function rand() { x ^= x << 13; x >>>= 0; x ^= x >>> 17; x ^= x << 5; x >>>= 0; return x / 4294967296; }

What the symbols mean

SymbolMeaning
seedSeed (integer ≥ 1)
r11st
r22nd
r33rd
u1st scaled to 0–1

More formulas in this category

Frequently asked questions

What is the formula for Pseudo-Random Numbers (xorshift)?
The formula for Pseudo-Random Numbers (xorshift) is x ^= x << 13; x ^= x >> 17; x ^= x << 5. Shifting bits and XOR-ing them produces a stream of numbers that look random.

Math Formula Quiz Math for Game Development

Sources

Checked: 2026-11-29