delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/25/01:50:19

Date: Thu, 25 May 2000 08:49:55 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Chris Miller <c DOT miller AT chemistry DOT uq DOT edu DOT au>
cc: djgpp AT delorie DOT com
Subject: Re: Random numbers
In-Reply-To: <392CB951.34B432E6@chemistry.uq.edu.au>
Message-ID: <Pine.SUN.3.91.1000525084705.21360M-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Thu, 25 May 2000, Chris Miller wrote:

> If RAND_MAX is set to 100, then a call to rand() should return an
> integer between 0 and 100.  However, on my computer, a call to rand()
> generates a number between what appears to be hundreds of millions and
> 0, even with RAND_MAX set to 100.

You cannot control `rand' by setting RAND_MAX, it is a constant that 
tells you what is the range of numbers produced by `rand'.  Changing its 
value will have no effect, since when `rand' was compiled, it used the 
original value.

The recommended way to generate random numbers from a smaller range is
described in section 22.23 of the DJGPP FAQ list, which see.

- Raw text -


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