delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/27/02:55:36

From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: getting a ranged random number, how?
Date: Sun, 27 Dec 1998 02:01:11 -0500
References: <3685970D DOT 271BE4C6 AT market DOT forsale> <pWfh2.1536$fz5 DOT 121 AT tundra DOT ops DOT attcanada DOT net>
X-Posted-Path-Was: not-for-mail
X-Accept-Language: en
X-ELN-Date: 27 Dec 1998 07:01:35 GMT
X-ELN-Insert-Date: Sat Dec 26 23:05:04 1998
Organization: Nocturnal Aviation
Lines: 17
Mime-Version: 1.0
NNTP-Posting-Host: 1cust133.tnt14.nyc3.da.uu.net
Message-ID: <3685DB37.3EC8E298@earthlink.net>
X-Mailer: Mozilla 4.5 [en] (Win95; I)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

DeHackEd wrote:
> 
> A common practice is to do this:
> 
> int num = rand() % max;
> 
> Num now contains a number between 0 and (max - 1). If max is 10, it holds from 0
> to 9. Does this help?

It shouldn't help.  If it is a common practice, then common practice is
bad.  Get and read the comp.lang.c FAQ from
ftp://rtfm.mit.edu/pub/usenet/


-- 
Martin Ambuhl (mambuhl AT earthlink DOT net)
Note: mambuhl AT tiac DOT net will soon be inactive

- Raw text -


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