Flash Gordon <> writes:
> CBFalconer wrote:
[...]
>> Oh? Are you claiming that you can back up and find the previous
>> value emitted by rand? I don't think that is guaranteed.
>
> Wrong, it is guaranteed.
>
> The description of srand includes the following which explicitly
> guarantees that you can:
>
> | The srand function uses the argument as a seed for a new sequence of
> | pseudo-random numbers to be returned by subsequent calls torand. If
> | srand is then called with the same seed value, the sequence of
> | pseudo-random numbers shall be repeated. If rand is called before
> | any calls to srand have been made, the same sequence shall be
> | generated as when srand is rst called with a seed value of 1.
Yes, that means you can recover the previous value returned by rand()
*if* you've remembered the original value passed to srand() and the
number of times rand() has been called since then. But then you might
as well just remember the previous value returned by rand().
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"