Date: Sun, 15 Jun 1997 12:05:02 +0300 (IDT) From: Eli Zaretskii To: Ben N Shadwick cc: djgpp AT delorie DOT com Subject: Re: rawclock() and other time.h functions In-Reply-To: <19970612.170431.8822.3.bshadwick@juno.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Thu, 12 Jun 1997, Ben N Shadwick wrote: > >The bug is in the docs, not in the code. The next release will fix > >the docs. > > I don't believe you. Why? Did I ever lie to you in the past? > What good does a bunch of functions that always > return zero the first time you call them do (besides giving you four > hundred ways to measure how fast your program is)? There are a lot of use for such function that only need relative times. Anyway, I didn't write that function, so I can't give you the real reason why it was designed this way. When this inconsistency was first reported, DJ Delorie said that the docs were in error, not the code. > IMHO, they have many > more applications when implemented the way the docs describe them - if > you need to use it the "returns-zero-the-first-time" way, just set some > variable equal to it and subtract its value to achieve the same effect. > On the other hand, if you need a quick way to know the number of seconds > (or clock ticks) since midnight, you have that too. It works both ways: you can always call any of the functions that return calendar time and the number of seconds since midnight to the values returned by `rawclock'. > Like Nate said, it only has a 1 second accuracy that way (not very > desirable) Do you really need to start a random sequence more than once per second? Anyway, if you do, you can call `gettimeofday' (which has a microsecond resolution). Another way to solve this problem is to call the random generator repetitively until it returns a value different from the previously-used one.