delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/29/10:24:28

Message-Id: <199907290807.EAA05343@delorie.com>
From: "Dan Gold" <TedMat AT CoastNet DOT com>
To: <djgpp AT delorie DOT com>
Subject: Re: -- Random question --
Date: Wed, 27 Jan 1999 16:27:22 -0800
X-MSMail-Priority: Normal
X-Priority: 3
X-Mailer: Microsoft Internet Mail 4.70.1155
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

Use rand()%256 for number between 0 and 255.  

----------
> From: Börje Granberg <borje DOT granberg AT ebox DOT tninet DOT se>
> To: djgpp AT delorie DOT com
> Subject: -- Random question --
> Date: Saturday, July 24, 1999 10:29 AM
> 
> I know there are commands like rand() and random() but how do I get a
random
> number between 1 and 100?
> 
> In BASIC it is easy because there you get a random (float) number between
0
> and 1 that you can multiplicate with 100 and add 1, but I dont see that
> opportunity in C++ or have my eyes missed that part?
> 
> 
> --
> /Börje
> 
> 
> 

- Raw text -


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