wiki

Help! I'm trapped in a wiki!

Site Tools


linux:random_numbers

Random numbers

Linux /dev/urandom

Basically open /dev/urandom as normal files, read from them, convert read data to an int modulo some number to get a desired range.
See this stackoverflow answer for more: https://stackoverflow.com/a/2572373

srand

Seed the prng with srand and get one with rand:

srand(12847124);
int randomValue = rand();
linux/random_numbers.txt · Last modified: by 127.0.0.1