Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is qrand() guaranteed to generate the same sequence with same seed across different platforms?

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    utcenter
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      QtRoS
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DerManu
        wrote on last edited by
        #3

        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;@

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved