Skip to content

Instantly share code, notes, and snippets.

@tftio
Created September 15, 2015 20:15
Show Gist options
  • Save tftio/8c94621ecbfdaf4c9e94 to your computer and use it in GitHub Desktop.
Save tftio/8c94621ecbfdaf4c9e94 to your computer and use it in GitHub Desktop.
Random number in [0:1)
#include <random>
#include <iostream>
// c++ -Wall -Werror -Wpedantic --std=c++11 -o ~/bin/random random.cpp
int main () {
std::random_device rd;
std::mt19937 mt(rd());
std::uniform_real_distribution<double> dist(0, 1);
std::cout << dist(mt) << std::endl;
return(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment