Mail Archives: djgpp/1997/06/15/05:06:32
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.
- Raw text -