Quote:
Originally Posted by AmXDusT
Just for curiosity
PHP Code:
// random_mod(max): A small function to give a random number from 0 to max-1. Useful for get random values from arrays
#define random_mod(%1) (random_num(0, (100 * (%1)) - 1) % (%1))
Is there any use of getting random that way instead of simply "random_num( 0, (%1) - 1 )"?
|
This one i can reply right away (i will answer the other one, when i get home from work):
I always disliked how random_num gives results that looks "not so random" when using small numbers, so i make a big random number and apply modulo on it to get a value from 0-(%1 - 1)
Of course, this is just personal opinion... But i have noticed the differences while using it and i'm happy with it.