0

Truly random number - If srand won't generate duplicate number, what happen if the range of random number finish generated?

If 1+rand()%6 gives 1-6, does it mean after it generates 6 times the program will halt or reset the pool and generate again?

6th Sep 2016, 12:24 AM
Chantastic Nyan-Nyan
Chantastic Nyan-Nyan - avatar
2 Respostas
+ 1
No. The output of rand and the modulo are two separate things. rand will only start to give the same numbers after 2^32 times.
6th Sep 2016, 8:49 AM
Zen
Zen - avatar
0
I know but is there a way to achieve truly random number without using mt19937 and array+rand?
6th Sep 2016, 11:40 PM
Chantastic Nyan-Nyan
Chantastic Nyan-Nyan - avatar