Potential bug in floop.c
Chris Torek
chris at umcp-cs.UUCP
Fri Jul 12 10:26:44 AEST 1985
While I'm thinking about it, there's some int==long assumptions
in floop.c, where it declares
long time();
and then proceeds to
srand (time ((long *) 0));
This should be changed to
srand ((int) time ((long *) 0));
(It will work on any stack machine that pushes and pops the arguments
to functions in the caller rather than the callee... which is most if
not all Unix machines. Nevertheless it is kind of sloppy.)
In addition,
long rand();
is missing (is rand() really a function returning long?) so that the
code that takes rand()>>16 will always give 0 on 16-bitters. (The
shift is only because rand is so un-random in the low order bits,
as you can visually demonstrate by taking it out....)
If you have a better random number generator than srand/rand, you might
want to use it instead.
(Why do I always think of the last bug while driving home?)
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP: seismo!umcp-cs!chris
CSNet: chris at umcp-cs ARPA: chris at maryland
More information about the Comp.sources.bugs
mailing list