Article View: net.bugs
Article #408Re: Bug in rand() and srand()
From: Guy Harris
Date: Wed, 06 Mar 1985 17:02
Date: Wed, 06 Mar 1985 17:02
14 lines
1431 bytes
1431 bytes
> rand uses a 32bit multiplicative random number generator. These generators
> tend to generate a repeating sequence in the lower bits. On the pdp 11
> the generator used a long and the returned value was shifted right by 16
> bits to get an int. The horribly behaved lower bits never hit the user.
> On the vax the how 32 bit item is returned.
Well, to be specific, on the VAX under 4.xBSD the 32 bit item is returned.
The System {III,V} systems still return the upper 16 bits. This means that any
program that assumes "rand" returns something in the range 0 <= N < MAX16BITINT
will work on all UNIX systems on machines with 16-bit "int"s and on all System
N systems, but won't work right on 4.xBSD systems. Grumble grumble...
--
Guy Harris
{seismo,ihnp4,allegra}!rlgvax!guy
Technical Details
Message-ID:
<557@rlgvax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!rlgvax!guyReferences:
<320@cubsvax.UUCP> <433@lll-crg.ARPA>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site rlgvax.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!panda!talcott!harvard!seismo!rlgvax!guy From: guy@rlgvax.UUCP (Guy Harris) Newsgroups: net.bugs,net.unix,net.lang.c,net.math Subject: Re: Bug in rand() and srand() Message-ID: <557@rlgvax.UUCP> Date: Wed, 6-Mar-85 12:02:46 EST Article-I.D.: rlgvax.557 Posted: Wed Mar 6 12:02:46 1985 Date-Received: Fri, 8-Mar-85 03:43:55 EST References: <320@cubsvax.UUCP> <433@lll-crg.ARPA> Organization: CCI Office Systems Group, Reston, VA Lines: 14