Bug in rand() and srand()
jpk at ur-univax.UUCP
jpk at ur-univax.UUCP
Fri Mar 15 08:28:00 AEST 1985
The same bug in rand() appears on the VMS C compiler (VAX-11 C)!
When I reported it to DEC, they had never discovered it.
I happened to find it because I was using rand() to generate
a random noise graphic, and discovered an awful lot of pattern
in a supposedly randomly generated display. What happened was
I made two successive calls to rand() to generate an x and y
coordinate, so all my x's fell on odd spaces, all my y's on
even. Half the points were never chosen on my screen, and
a very regular half!
The fix was to call MTH$RANDOM on VMS, and random() on unix.
The moral: compatible function libraries don't support compatible
systems when the original version was bugged! Instead, they
support bugged, but compatible, code. Equally wrong on VMS
or unix!!!
-- Jon Krueger
More information about the Net.bugs
mailing list