Skip to content

Commit

Permalink
Fix linear congruential random number generator
Browse files Browse the repository at this point in the history
Fixes: #4146, #4148, #4270
Fixes: 2252936 ("Use linear congruential random number generator [...]")
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Nov 22, 2024
1 parent 5c78037 commit 32fee19
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/ccutil/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ inline const std::vector<std::string> split(const std::string &s, char c) {
return v;
}

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

private:
std::minstd_rand e;
std::linear_congruential_engine<std::uint_fast32_t,
6364136223846793005ULL,
1442695040888963407ULL,
UINT64_MAX> e;
};

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

0 comments on commit 32fee19

Please sign in to comment.