We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 93489f7 commit 503d398Copy full SHA for 503d398
1 file changed
test/test.js
@@ -4,12 +4,15 @@ import assert from 'assert';
4
import { String_random } from '../lib/String_random.js';
5
import test from 'node:test';
6
7
-// シード付き乱数生成器
+// シード付き乱数生成器(Xorshift32)
8
function seededRandom(seed) {
9
- let x = Math.sin(seed) * 10000;
+ let x = seed >>> 0;
10
return function() {
11
- x = Math.sin(x) * 10000;
12
- return x - Math.floor(x);
+ // Xorshift32アルゴリズム
+ x ^= x << 13;
13
+ x ^= x >>> 17;
14
+ x ^= x << 5;
15
+ return (x >>> 0) / 0x100000000;
16
};
17
}
18
const random = seededRandom(42);
0 commit comments