[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lua-l
Subject:    randomseed [Re: Bug? in mathlib's random()]
From:       Roberto Ierusalimschy <roberto () inf ! puc-rio ! br>
Date:       1999-08-23 13:11:16
Message-ID: 199908231309.KAA07035 () obatala ! inf ! puc-rio ! br
[Download RAW message or body]

>    The trouble is, when using Lua as a stand-alone, there's no good way to
> "randomly" seed the RNG -- date() returns a string,

If you call "date" with appropriate arguments, it returns a string in
numeric format, which is then converted to a number when used as argument
to randomseed. For instance, if you call

  randomseed(date"%H%M%S")

your seed is a concatenation of the current hour-minutes-seconds (pretty
close to "real" time for random purposes).

-- Roberto

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic