View Full Version : Random?
09-16-2007, 09:03 AM
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?
09-16-2007, 12:47 PM
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.
vBulletin® v3.6.4, Copyright ©2000-2013, Jelsoft Enterprises Ltd.