in reply to Re^2: rand and srand across builds and platforms?
in thread rand and srand across builds and platforms?

OS X is basically Mach with a FreeBSD userland, so pretty much so yes.

  • Comment on Re^3: rand and srand across builds and platforms?

Replies are listed 'Best First'.
Re^4: rand and srand across builds and platforms?
by BrowserUk (Patriarch) on Mar 08, 2005 at 18:10 UTC

    Which as you are getting different values from those on Linux builds scotches the "compatible across POSIX platforms" idea.


    Examine what is said, not who speaks.
    Silence betokens consent.
    Love the truth but pardon error.

      Yeah, looks to be. On a whim I checked on an x86 FreeBSD 5 box and got the same numbers I got on OS X. So it looks to be definitely tied to the libc underneath. You might could get by with stubbing out a hash of the n values you're expecting for different values of $^X . . . .

        Thanks for doing that.

        You might could get by with stubbing out a hash of the n values...

        If I could just store one srand seed per OS, and the rand function would generate the same sequence from that point on that might work. But even if it is the same generator and just platform specific seeding, finding which seed caused the sequence I need on each platform would be a labour of love ;)

        As it it, I'll just generate a big batch of random tests recording the rands used to generate them and then pick the best/most difficult etc. and embed the sequences into the testcases.


        Examine what is said, not who speaks.
        Silence betokens consent.
        Love the truth but pardon error.