2024.js/lib/prng.ts

11 lines
267 B
TypeScript
Raw Normal View History

2024-01-12 21:35:35 -05:00
export type Prng = () => number;
export function mulberry32(state: number) {
return function () {
let t = (state += 0x6d2b79f5);
t = Math.imul(t ^ (t >>> 15), t | 1);
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
return (t ^ (t >>> 14)) >>> 0;
};
}