Created
February 21, 2023 11:42
-
-
Save THM-T/9f01c6cb2d53b77d2d63aefe1d405d9e to your computer and use it in GitHub Desktop.
Generate Random double that bounded in Qt (QRandomGenerator64)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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