| delorie.com/archives/browse.cgi | search |
| From: | Erik Max Francis <max AT alcyone DOT com> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: Random interger numbers |
| Date: | Tue, 24 Mar 1998 00:58:59 -0800 |
| Organization: | Alcyone Systems |
| Lines: | 21 |
| Message-ID: | <351775D3.A773768@alcyone.com> |
| References: | <01bd56dd$5d636c80$0f02000a AT frank DOT mtsu DOT edu DOT frank DOT mtsu DOT edu> |
| NNTP-Posting-Host: | charmaine.alcyone.com |
| Mime-Version: | 1.0 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Nathan Cournia wrote:
> What I need
> is a function that will act as a (n) sided dice. Thanks for the help.
Use
rand()%n + 1
which will give you a random number betwen 1 and n, inclusive.
Note that pseudorandom number generators tend to be poor in their lower
significant bits, so this is sometimes not an ideal solution.
--
Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com
Alcyone Systems / http://www.alcyone.com/max/
San Jose, California, United States / icbm:+37.20.07/-121.53.38
\
"I've got the fever for the / flavor of a cracker"
/ Ice Cube
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |