[chuck-users] easy random numbers
Scott Wheeler
wheeler at kde.org
Wed Nov 21 15:15:19 EST 2007
jakob kaiser wrote:
> > Uhm, I still don't get it. I tried your example on two platforms
> > yesterday (Mac and Windows -- my Linux machine is 64-bit) and the
> > numbers are random -- with the exception of the first one
>
> Strange, On my windowsXP system I get excatly the same numbers every
> time I start the code:
> 51 :(int)
> 585 :(int)
> 233 :(int)
> 819 :(int)
> 606 :(int)
> 506 :(int)
> ...and infinitely more numbers
>
> This relationship between the numbers seems randomly enough, but 51 is
> always the first, 585 is always the second one, and so on. Therefor it
> does not seem to use the system time. (At least not with my version,
> but I am using the latest precompiled one for windows)
I found the pattern -- I was using "--silent" on Windows. Windows seems
to use the number of milliseconds since the program started running in
its computation of rand(). If you remove the 1::second => now from the
loop the numbers are in fact random. Effectively using --silent did
that to my runs (since durations aren't respected then). All of the
different durations that I tried in your loop seem to produce a
different, repeated sequence.
-Scott
More information about the chuck-users
mailing list