Random.h File Reference

Go to the source code of this file.

Functions

void InitializeRandomNumber ()
unsigned int RandomNumber (const unsigned int range)
double RandomProb ()

Function Documentation

void InitializeRandomNumber (  ) 

Definition at line 38 of file Random.cpp.

00039 {
00040     srand( time( NULL ));
00041 }

unsigned int RandomNumber ( const unsigned int  range  ) 

Definition at line 44 of file Random.cpp.

00045 {
00046     unsigned int result;
00047 
00048     // random number precision is 28 bits
00049     // return number out of range if range is larger than 28 bits
00050     if( range > 0xfffffff )
00051         return 0xffffffff;
00052     result = ( rand() << 15 ) + rand();
00053     result = result % range;
00054     return result;
00055 }

double RandomProb (  ) 

Definition at line 58 of file Random.cpp.

00059 {
00060     double x = (( double ) RandomNumber( 0xfffffff ) ) / ( 0xfffffff );
00061     return x;
00062 }

Generated on Wed Jul 4 16:03:30 2012 for RIO by  doxygen 1.6.3