PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

RAND_MAX

does anybody now how to set rand max so u get a random number between 0 and 10?
Just mod it by your max value plus 1:
[fixed]int i = rand() % 11;
//i>=0 && i<=10[/fixed]

Dan East
int i = ((rand() / (double)RAND_MAX) * 10.0)
thanx dude.
i mean, thanx to both
We all just about posted right on top of each other. :)

Dan East
I think I like your solution better though, less operations.
Yes, really cool this mod operator ;-)