delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/18/19:45:45

From: "A. Sinan Unur" <sinan DOT unur AT cornell DOT edu>
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
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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/

- Raw text -


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