Skip to content

Instantly share code, notes, and snippets.

@PaulChana
Last active March 12, 2018 11:49
Show Gist options
  • Save PaulChana/bbb8d564fc5f55509e01cf1957449cd9 to your computer and use it in GitHub Desktop.
Save PaulChana/bbb8d564fc5f55509e01cf1957449cd9 to your computer and use it in GitHub Desktop.
C++ uniform distribution random numbers
#include <random>
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(1, 6);
const int rnd = dis(gen);
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_real_distribution<> dis(-1.f, 1.f);
const float rnd = dis(gen);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment