Skip to content

Commit 32fee19

Browse files
committed
Fix linear congruential random number generator
Fixes: #4146, #4148, #4270 Fixes: 2252936 ("Use linear congruential random number generator [...]") Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 5c78037 commit 32fee19

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/ccutil/helpers.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ inline const std::vector<std::string> split(const std::string &s, char c) {
6868
return v;
6969
}
7070

71-
// A simple linear congruential random number generator.
71+
// A simple linear congruential random number generator,
72+
// using Knuth's constants from:
73+
// http://en.wikipedia.org/wiki/Linear_congruential_generator.
7274
class TRand {
7375
public:
7476
// Sets the seed to the given value.
@@ -95,7 +97,10 @@ class TRand {
9597
}
9698

9799
private:
98-
std::minstd_rand e;
100+
std::linear_congruential_engine<std::uint_fast32_t,
101+
6364136223846793005ULL,
102+
1442695040888963407ULL,
103+
UINT64_MAX> e;
99104
};
100105

101106
// Remove newline (if any) at the end of the string.

0 commit comments

Comments
 (0)