X-Authentication-Warning: acp3bf.physik.rwth-aachen.de: broeker owned process doing -bs Date: Tue, 17 Nov 1998 14:06:41 +0100 (MET) From: Hans-Bernhard Broeker X-Sender: broeker AT acp3bf To: djgpp-workers AT delorie DOT com Subject: Re: src/libc/ansi/stdlib/rand.c In-Reply-To: <365079C2.5052B140@cyberoptics.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com On Mon, 16 Nov 1998, Eric Rudd wrote: > I don't have my copy of C90 with me, but in the latest draft of C9x the > behavior is defined even when srand() is not called first: > > 7.20.2.2 The srand function > > Synopsis > > [#1] > > #include > void srand(unsigned int seed); > > Description > > [#2] The srand function uses the argument as a seed for a > new sequence of pseudo-random numbers to be returned by > subsequent calls to rand. 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 first called with a seed value of 1. Just for the record: this essentially unchanged from ANSI C89. > No matter how rand() and srand() are implemented, someone is always going > to be surprised. The surprised party ought to be the careless programmer > who hasn't read the C standard, rather than the careful programmer who has. I second that. The standard is way too important to break compliance just to please programmers who can't be bothered to read any kind of documentation. And, to set that straight: this issue is fundamentally different from the change in 2.02 to automatically fflush(stdout) after each printf(). That detail is left open to the implementor, by the standard, so we don't violate the standard either by the old way, nor be the proposed new one. (We're just making stdout unbuffered, instead of line-buffered). Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.