On Wednesday, 19 February 2003 at  9:22:18 -0800, Wes Peters wrote:
> On Tuesday 18 February 2003 22:36, Peter Jeremy wrote:
>>
>> I see this as a major advantage of arc4random() - if I want 32-bit
>> random numbers I don't have to call random() twice and merge the
>> results.  I've never understood why random() was specified to return
>> a '0' in the MSB.
>
> It probably had something to do with the PDP-11 architecture.  This
> rings a bell, but I can't recall what it was.  Greg Lehey might be
> able to help here, he has far better knowlege of the Good Old Days(tm)
> than I do. 

Difficult to say.  I don't think that random() was in the Seventh
Edition.  They used rand() instead.  Read the code and shudder:

static  long    randx = 1;

srand(x)
unsigned x;
{
        randx = x;
}

rand()
{
        return(((randx = randx*1103515245 + 12345)>>16) & 077777);
}

That's the entire content of Seventh Edition /usr/src/libc/gen/rand.c.

Greg
--
See complete headers for address and phone numbers
Please note: we block mail from major spammers, notably yahoo.com.
See http://www.lemis.com/yahoospam.html for further details.

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to