Mail Archives: djgpp-workers/1998/11/16/13:53:52
Dear Eli Zaretskii,
On 11-16-98 at 04:25:17 EST you wrote:
>
> Doesn't this violate the ANSI Standard? My references indicate that
> it requires the implementation to ``behave as if the target
> environment calls "srand(1)" at program startup.'' (Which also means
> that `next' should start with 1, not 0.)
>
Please cite the references. As nearly as I can determine, and as stated
in "The Standard C library," (page 350) 'The behavior of *rand* can vary
among implementations.'
> I think most people would expect `rand' to produce the same sequence
> unless they called `srand', even if ANSI doesn't mandate it.
>
You have a point. But learned usage should prompt a user to call
*srand* with the same parameter to get a deterministic result.
>
> I think ANSI specifies that ``implementation shall behave as if no
> library function calls the `rand' function.'' If I'm right, this
> violates that requirement. (Why are the calls to `rand' a good idea,
> anyway?)
The extra calls cleanse the generator. I'd like to see about 50 calls
but three might be enough.
K.B. Williams
- Raw text -