mirror of
https://github.com/janet-lang/janet
synced 2025-01-13 00:50:26 +00:00
Improve randomness of numbers from new rng.
First few numbers are very biased.
This commit is contained in:
parent
6b76ac3d18
commit
16f6261b44
@ -70,6 +70,8 @@ void janet_rng_seed(JanetRNG *rng, uint32_t seed) {
|
|||||||
rng->c = 0x17af0931u;
|
rng->c = 0x17af0931u;
|
||||||
rng->d = 0xFFFaaFFFu;
|
rng->d = 0xFFFaaFFFu;
|
||||||
rng->counter = 0u;
|
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) {
|
uint32_t janet_rng_u32(JanetRNG *rng) {
|
||||||
|
@ -226,6 +226,7 @@
|
|||||||
(with-dyns [:out @""]
|
(with-dyns [:out @""]
|
||||||
(prin "abcd")
|
(prin "abcd")
|
||||||
(prin (dyn :out))
|
(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)
|
(end-suite)
|
||||||
|
Loading…
Reference in New Issue
Block a user