🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.bugs
Article #418

Re: Bug in rand() and srand()

#418
From: jpk
Date: Thu, 14 Mar 1985 22:28
19 lines
1510 bytes
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
Technical Details
Message-ID: <2600001@ur-univax.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!rochester!ur-univax!jpk
References: <320@cubsvax.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: nyu notesfiles V1.1 4/1/84; site ur-univax.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!rochester!ur-univax!jpk
From: jpk@ur-univax.UUCP
Newsgroups: net.bugs
Subject: Re: Bug in rand() and srand()
Message-ID: <2600001@ur-univax.UUCP>
Date: Thu, 14-Mar-85 17:28:00 EST
Article-I.D.: ur-univa.2600001
Posted: Thu Mar 14 17:28:00 1985
Date-Received: Sat, 16-Mar-85 04:32:59 EST
References: <320@cubsvax.UUCP>
Organization: University of Rochester: Computing Center
Lines: 19
Nf-ID: #R:cubsvax:-32000:ur-univax:2600001:000:794
Nf-From: ur-univax!jpk    Mar 14 17:28:00 1985