www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/22/10:44:18

From: Edward Hill <edward_hill AT gec DOT nospam DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: rand() function
Date: Thu, 21 Jan 1999 15:19:02 -0800
Organization: Easams, Engineering Systems
Lines: 17
Message-ID: <36A7B5E6.656D@gec.nospam.com>
References: <36A72C2A DOT 3DAF8CFE AT cryogen DOT com> <787bpa$5da$1 AT antares DOT lu DOT erisoft DOT se>
NNTP-Posting-Host: pc02372.gmsws.gecm.com
Mime-Version: 1.0
X-Mailer: Mozilla 3.01C-GECMMTL (Win95; I; 16bit)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Martin Stromberg wrote:
: 
: FireFoX McLouD (firefox AT cryogen DOT com) wrote:
: : How can I redefine the RAND_MAX parameter to use rand() with low
: : numbers?
: 
: You can't; it's not there to change.


try 
 int random;
 random = (int)((double)rand() / ((double)RAND_MAX + 1) * N)

will give a random number from 0 - N
don't forget to set the seed though.

Ed Hill

- Raw text -


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