Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Random? (http://www.chiefdelphi.com/forums/showthread.php?t=58785)

TexasFederation 16-09-2007 10:03

Random?
 
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

Re: Random?
 
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.


All times are GMT -5. The time now is 00:19.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi