Log in

View Full Version : Random?


TexasFederation
16-09-2007, 10:03
I have EasyC V2 and downloaded the trial version of easyC Pro. I don't find a random function in either program. Is there a reason for that or is there a workaround?

artdutra04
16-09-2007, 13:47
A "pure" random number generator does not exist in either. However, you can make a pseudo-random number generator that's a close enough approximation:

Start a timer before the program:
Each time through the loop, divide the timer value by a number like four or nine*, and store the modulus to a variable.
The modulus (the % operator) is now your "random" number.


* The size of your random number pool will depend on how high you set this. If you want a bigger range of random numbers, set this higher.