Skip to content

Instantly share code, notes, and snippets.

@THM-T
Created February 21, 2023 11:42
Show Gist options
  • Save THM-T/9f01c6cb2d53b77d2d63aefe1d405d9e to your computer and use it in GitHub Desktop.
Save THM-T/9f01c6cb2d53b77d2d63aefe1d405d9e to your computer and use it in GitHub Desktop.
Generate Random double that bounded in Qt (QRandomGenerator64)
#include <QRandomGenerator64>
template <std::size_t P = 10'000>
static double randomGenrate(double begin, double end) {
static auto randomGenrator = QRandomGenerator64::global();
auto rand = randomGenrator->bounded(static_cast<int>(begin * P),
static_cast<int>(end * P));
return static_cast<double>(rand) / P;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment