[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Random (Was: Cannot run KDE snapshot :()
From: Waldo Bastian <bastian () suse ! de>
Date: 1999-12-10 9:19:28
[Download RAW message or body]
On Fri, 10 Dec 1999, Stephan Kulow wrote:
> Alex Zepeda wrote:
> >
> > On Thu, 9 Dec 1999, Stephan Kulow wrote:
> >
> > > > Do you know of any better way to get a random number?
> > > >
> > > Well, you could as a compromise reset the random seed
> >
> > How? Wouldn't you have to have root access to set the clock?
> >
> What has the clock to do with the random seed? Nothing inspite
> that most people abuse the clock for getting a semi random start
> seed. The problem comes if you use the KTempFile constructor
> more than once in a second, it will init the seed with the same
> number resulting in the same output.
Hm interesting. That could cause a problem when you need more than 3
tempfiles within a second.
Can't we init the random seed in KApplication and make it a policy not
to touch the random seed? If you need reproducable sequences just write
your own sequence generator. (That's not too difficult, I just need to
dig out my math books.)
We could provide:
int KApplication::random() // Generate a truly unpredictable number.
and
class KSequence // Generate a random sequence
{
public:
KSequence(int seed=0);
int number();
private:
....
}
KSequence(N) initialize the sequence with N for N >0 and with
kapp->random() for N == 0.
Cheers,
Waldo
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic