www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/26/21:25:11

From: "DeHackEd" <notgiven AT out DOT com>
Newsgroups: comp.os.msdos.djgpp
References: <3685970D DOT 271BE4C6 AT market DOT forsale>
Subject: Re: getting a ranged random number, how?
Lines: 16
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.0810.800
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.0810.800
Message-ID: <pWfh2.1536$fz5.121@tundra.ops.attcanada.net>
Date: Sat, 26 Dec 1998 21:22:52 -0500
NNTP-Posting-Host: 142.194.222.245
X-Trace: tundra.ops.attcanada.net 914721557 142.194.222.245 (Sun, 27 Dec 1998 01:19:17 GMT)
NNTP-Posting-Date: Sun, 27 Dec 1998 01:19:17 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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?


oranges <oranges AT market DOT forsale> wrote in message
news:3685970D DOT 271BE4C6 AT market DOT forsale...
>in turboc, there is a "max" argument in random() ..
>
>
>


- Raw text -


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