This is what I am using:



unsigned long RandomNum(unsigned long n)
{
 static Boolean initialized = false;

 unsigned long x;
 if (initialized == false) {
  initialized = true;
  SysRandom(TimGetTicks());
 }
 if (n == 0)
  n = 1;

 x = SysRandom(0) ;
 x = (double)  x / ( (double) (1 + sysRandomMax / n )) ;

 return x;
}



"Nils Raschke" <[EMAIL PROTECTED]> wrote in message news:68513@palm-dev-forum...

Hello,

I like to get a random number in the range from 1 to 6.

The function sysRandom() don�t allow to specify a range or an upper limit
(the highest possible number is defined in sysRandomMax, but I don�t think I
should change there anything).

Is there a way to get the desired result directly from sysRandom()?

Or, do I have to trim the value that I get from sysRandom() to my needs (if
so, in what header file I have to look to get the functions to get just the
first unit (numbers 0-9) of a number)?

Thanks in advance,
Nils






-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to