From: "A. Sinan Unur" Newsgroups: comp.os.msdos.djgpp Subject: Re: random numbers? Date: Sun, 18 Jan 1998 19:31:08 -0500 Organization: Cornell University (http://www.cornell.edu/) Lines: 17 Sender: asu1 AT cornell DOT edu (Verified) Message-ID: <34C29ECC.6F865D9E@cornell.edu> References: <34c2863d DOT 422495 AT news DOT ziplink DOT net> NNTP-Posting-Host: cu-dialup-0078.cit.cornell.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Jeff W./DMT wrote: > > how do I get a random number from 0 to N in DJGPP? I tried looking > up: random, srandom, and rand but none seem to help. SRand says it > returns a number from 0 to RAND_MAX, and random returns a numbre from > 0 to MAX_INT. Neither is what I'm looking for. Thanks for your help. (int)( N*( ((double)rand())/RAND_MAX ) -- ---------------------------------------------------------------------- A. Sinan Unur Department of Policy Analysis and Management, College of Human Ecology, Cornell University, Ithaca, NY 14853, USA mailto:sinan DOT unur AT cornell DOT edu http://www.people.cornell.edu/pages/asu1/