1
0
mirror of https://github.com/janet-lang/janet synced 2025-01-12 16:40:27 +00:00

Improve randomness of numbers from new rng.

First few numbers are very biased.
This commit is contained in:
Calvin Rose 2019-11-10 17:44:59 -06:00
parent 6b76ac3d18
commit 16f6261b44
2 changed files with 4 additions and 1 deletions

View File

@ -70,6 +70,8 @@ void janet_rng_seed(JanetRNG *rng, uint32_t seed) {
rng->c = 0x17af0931u;
rng->d = 0xFFFaaFFFu;
rng->counter = 0u;
/* First several numbers aren't that random. */
for (int i = 0; i < 16; i++) janet_rng_u32(rng);
}
uint32_t janet_rng_u32(JanetRNG *rng) {

View File

@ -226,6 +226,7 @@
(with-dyns [:out @""]
(prin "abcd")
(prin (dyn :out))
(assert (deep= (dyn :out) @"abcdabcd") "print buffer to self"))
(prin (dyn :out))
(assert (deep= (dyn :out) @"abcdabcdabcdabcd") "print buffer to self"))
(end-suite)