Skip to content

Instantly share code, notes, and snippets.

@JAChapmanII
Last active September 16, 2015 17:16
Show Gist options
  • Save JAChapmanII/aefbebc0f6308899ce9e to your computer and use it in GitHub Desktop.
Save JAChapmanII/aefbebc0f6308899ce9e to your computer and use it in GitHub Desktop.
c++ rand
#include <random>
using std::random_device;
using std::uniform_int_distribution;
using std::generate_canonical;
int main(int, char **) {
// makes random numbers
random_device engine{};
// generate in [0, 2]
uniform_int_distribution<int> uid{0, 2};
auto result = uid(engine);
// generate in [0, 1), 10 bits
auto zeroToOne = generate_canonical<double, 10>(engine);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment