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: 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
Xref: watmath net.bugs:562 net.unix:3850 net.lang.c:4667 net.math:1880

> 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