This site is no longer active and is available for archival purposes only. Registration and login is disabled.

RAND_MAX


RAND_MAX

Postby daburnd » Oct 2, 2001 @ 2:18pm

does anybody now how to set rand max so u get a random number between 0 and 10?
daburnd
 


Re: RAND_MAX

Postby Dan East » Oct 2, 2001 @ 2:43pm

Just mod it by your max value plus 1:<br>[fixed]int i = rand() % 11;<br>//i>=0 && i<=10[/fixed]<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: RAND_MAX

Postby RICoder » Oct 2, 2001 @ 2:44pm

int i = ((rand() / (double)RAND_MAX) * 10.0)
<iframe src="http://gamercard.xbox.com/RICoder.card" scrolling="no" frameBorder="0" height="140" width="204">RICoder</iframe>
User avatar
RICoder
FOX News Correspondent
 
Posts: 3948
Joined: Jul 10, 2001 @ 1:48pm
Location: the matrix has me


Re: RAND_MAX

Postby daburnd » Oct 2, 2001 @ 2:45pm

thanx dude.
daburnd
 


Re: RAND_MAX

Postby daburnd » Oct 2, 2001 @ 2:46pm

i mean, thanx to both
daburnd
 


Re: RAND_MAX

Postby Dan East » Oct 2, 2001 @ 2:55pm

We all just about posted right on top of each other. :)<br><br>Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Re: RAND_MAX

Postby RICoder » Oct 2, 2001 @ 2:58pm

I think I like your solution better though, less operations.
<iframe src="http://gamercard.xbox.com/RICoder.card" scrolling="no" frameBorder="0" height="140" width="204">RICoder</iframe>
User avatar
RICoder
FOX News Correspondent
 
Posts: 3948
Joined: Jul 10, 2001 @ 1:48pm
Location: the matrix has me


Re: RAND_MAX

Postby boris_fr » Oct 2, 2001 @ 3:10pm

Yes, really cool this mod operator ;-)
Boris
User avatar
boris_fr
pm Member
 
Posts: 13
Joined: Sep 26, 2001 @ 3:57pm
Location: France


Return to Phantom's Forum


Sort


Forum Description

Discuss any of Phantom's projects here (Operation Nutcracker, etc.)

Moderators:

sponge, RICoder, Phantom

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron