Is qrand() guaranteed to generate the same sequence with same seed across different platforms?



  • I need to generate pseudo random data for benchmarking purposes, so in order to have uniformity of the results across different platforms I need to be able to generate the same random data. So the big question is, will qrand() generate the same pseudo random sequences on different platforms if the seed is the same?



  • Your question must be "will srand() generate the same pseudo random sequences on different platforms if the seed is the same", because qrand realized through srand, but guarantees thread-safety. And you can easily test it by hand. I think the answer in no.

    My opinion - you must use once generated sequence.



  • Why not save the time worrying about it and just write a pseudo random number generator yourself in 10 seconds? Then you know what you've got and for benchmarking you probably don't need high quality random numbers.
    @r = (r*1103515245+12345) & max;@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.