I have the following situation: I would like to generate M=500,000 unique random numbers between 1016 and 264-1. To simplify the situation, we can assume, that we need a number between 1 and N=264-1.
I already found references to this question >here< and >here< and >here<.
But I still have the feeling, that the methods mentioned in the references work if N is much smaller. I.e. it is no option to make a list of all numbers from 1 to N, mix them and take the first M. And somehow I think that there should be a much more effective way than try and error, since M<< N. And M<< N are always given. Therefore the algorithm has not to be good if N-M is small or even N=M. But somehow the big N gives me headache...
Related to this problem I tried to expand qrand() to get a random `quint64 with
quint64 MainWindow::longrand()
{
quint64 erg=(quint64)qrand();
for(int i=0;i<4;i++)
erg=(erg<<(RAND_MAX+1))+qrand();
erg=(erg<<16)+(qrand()%16);
return erg;
}
I know that this is not a very good random number, but will it be sufficent or will this gives a problem for some algorithm?