delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/25/00:55:30

Date: Tue, 24 Mar 1998 21:54:58 -0800 (PST)
Message-Id: <199803250554.VAA20256@adit.ap.net>
Mime-Version: 1.0
To: jalex AT ea DOT oac DOT uci DOT edu
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Source for random()?
Cc: djgpp AT delorie DOT com

At 03:58  3/24/1998 -0500, DJ Delorie wrote:
>
>>   What are the values of m,a, and c that random() uses?  (I'm assuming
>> it's a linear congruential random number generator, if not, please let
>> me know). I've looked up both rand() and random() using info, but they
>> don't provide the specific formula.
>
>Read the source!

This is of course the right answer. I'll just amplify a bit:

`rand' is a LCRNG. `random' is significantly more complicated. I'm no expert
of numerical analysis, and in fact I don't understand `random' at all. (Not
that I've tried very hard :)

The appropriate source files, once you've unpacked the DJLSR package, are:

`rand': src/libc/ansi/stdlib/rand.c
`random': src/libc/compat/stdlib/random.c

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019