Random number generator (device): Difference between revisions

Content added Content deleted
m (→‎{{header|REXX}}: removed OVERFLOW from PRE html tag.)
(→‎{{header|C++}}: Removed unnecessary string header, changed int distribution to long so it actually is guaranteed to be 32-bit.)
Line 127: Line 127:
{{works with|C++11}}
{{works with|C++11}}
<lang cpp>#include <iostream>
<lang cpp>#include <iostream>
#include <string>
#include <random>
#include <random>
Line 133: Line 132:
{
{
std::random_device rd;
std::random_device rd;
std::uniform_int_distribution<int> dist;
std::uniform_int_distribution<long> dist; // long is guaranteed to be 32 bits
std::cout << "Random Number: " << dist(rd) << std::endl;
std::cout << "Random Number: " << dist(rd) << std::endl;