Subject: Re: [boost] [random] seeding with arbitrary integers
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-10-21 12:34:38
Robert Ramey wrote:
> Steven Watanabe wrote:
>> explicit linear_congruential_engine(result_type s = default_seed);
>> Effects: Constructs a linear_congruential_engine object. If c mod m
>> is 0 and s mod m is 0, sets
>> the engines state to 1, otherwise sets the engines state to s mod m.
> So I might be passing two different seeds and generate the same
> sequence of results? This would be the exact opposite of what I would
> be trying to do and would likely result in a silent error that would
> be a major bitch to find.
This is only a major problem if you explicitly pass the seed:
If the seed comes from somewhere else:
then either the library or the user has to fix it up.
Currently, the statement
will work almost all the time.
However, it is wrong because it will fail
when time(0) returns 2147483647.
Is it worse to fix things up and possibly have
multiple seeds yield that same sequence or
to let code like this fail randomly once in a
while? It seems to me that this bug is likely
to be harder to trace because it won't even
> This isn't so much a specifice critcism of this particular
> situation as I don't really understand the library or the
> standard. It's more of rant against the things that seem
> to trap me into spending disproportional amounts of time
> on a regular basis. This idea of "silently fixing things"
> seems to be quite popular and to me, is the cause of much
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk