Hello,
I'm using the code shown to generate random numbers.
timeval ti;
gettimeofday(&ti, NULL);
qsrand(qsrand((long long)ti.tv_usec * (long long)ti.tv_sec);
qDebug() << (long long)((long long)ti.tv_usec * (long long)ti.tv_sec);
num = (rand() % maxNum + 1);
timeval ti;
gettimeofday(&ti, NULL);
qsrand(qsrand((long long)ti.tv_usec * (long long)ti.tv_sec);
qDebug() << (long long)((long long)ti.tv_usec * (long long)ti.tv_sec);
num = (rand() % maxNum + 1);
To copy to clipboard, switch view to plain text mode
1151813750172254
1152103117531054
1020841750830240
1033346761335855
1151813750172254
1152103117531054
1020841750830240
1033346761335855
To copy to clipboard, switch view to plain text mode
Is there any difference to the result in using:-
qsrand((long long)ti.tv_usec * (long long)ti.tv_sec);
qsrand((long long)ti.tv_usec * (long long)ti.tv_sec);
To copy to clipboard, switch view to plain text mode
against
qsrand(ti.tv_usec * ti.tv_sec);
qsrand(ti.tv_usec * ti.tv_sec);
To copy to clipboard, switch view to plain text mode
Both seem to give acceptable results.
Regards
Bookmarks