#include <perms.h>

                                                                //      1  !%endoflist
                                                                //      2  !These Pseudo-random numbers were written by P. Reid.  It is not known if
                                                                //      3  !they are genuinely random or not.
                                                                //      4  
                                                                //      5  !**  %routine   INITALISE RANDOM    sets up the random integer SEED          **!
                                                                //      6  !**  %real %fn  RANDOM REAL (LO,HI) returns uniformly distributed reals      **!
                                                                //      7  !**                                 between LO and HI inclusive              **!
                                                                //      8  !**  %short %fn RANDOM INT (LO,HI)  returns uniformly distributed short      **!
                                                                //      9  !**                                 integers between LO and HI inclusive     **!
                                                                //     10  
                                                                //     11  %own %integer Seed=0  {initialised to 0: JHB mod 16/12/86}
#line 11 "regression-compile-tmp/random.imp"
static int SEED = 0;
                                                                //     12  
                                                                //     13  
                                                                //     14  %routine Initialise Random
#line 14 "regression-compile-tmp/random.imp"
void INITIALISERANDOM( void )
#line 14 "regression-compile-tmp/random.imp"
{
                                                                //     15  !
                                                                //     16  ! Set up SEED
                                                                //     17  !
                                                                //     18     Seed = CpuTime
#line 18 "regression-compile-tmp/random.imp"
SEED = _imp_CPUTIME();
                                                                //     19  %end
#line 19 "regression-compile-tmp/random.imp"
/* Remove %on %event handler here if present for this block */
return;
} // End of block INITIALISERANDOM at level 1
                                                                //     20  
                                                                //     21  
                                                                //     22  %realfn Random Real(%real Lo, Hi)
#line 22 "regression-compile-tmp/random.imp"
float RANDOMREAL( float LO, float HI )
#line 22 "regression-compile-tmp/random.imp"
{
                                                                //     23  !
                                                                //     24  ! Returns a random real between LO and HI inclusive
                                                                //     25  !
                                                                //     26     Seed = (23501*Seed + 6923) & 32767
#line 26 "regression-compile-tmp/random.imp"
SEED = (((((int)((((int)(23501)) * (SEED)))) + (6923))) & (32767));
/*Warning: potential loss of precision converting from integer AST_VAR (SEED - 4 bytes) to real AST_BINOP ((((float)(HI)) - (LO)) - 0 bytes) detected at ast.c line 108 */
                                                                //     27     %result = Lo + (Seed * (Hi - Lo))/32767
#line 27 "regression-compile-tmp/random.imp"
/* Remove %on %event handler here if present for this block */
return ((LO) + (((double)((double)(((((SEED)) * ((((float)(HI)) - (LO)))))) / (double)((float)(32767))))));
                                                                //     28  %end
#line 28 "regression-compile-tmp/random.imp"
} // End of block RANDOMREAL at level 1
                                                                //     29  
                                                                //     30  
                                                                //     31  %shortfn Random Int (%short Lo, Hi)
#line 31 "regression-compile-tmp/random.imp"
short RANDOMINT( short LO, short HI )
#line 31 "regression-compile-tmp/random.imp"
{
                                                                //     32  !
                                                                //     33  ! Returns a random shortinteger between LO and HI inclusive
                                                                //     34  !
                                                                //     35     Seed = (23501*Seed + 6923) & 32767
#line 35 "regression-compile-tmp/random.imp"
SEED = (((((int)((((int)(23501)) * (SEED)))) + (6923))) & (32767));
                                                                //     36     %result = Int(Lo + (Seed * (Hi - Lo))/32767)
#line 36 "regression-compile-tmp/random.imp"
/* Remove %on %event handler here if present for this block */
return _imp_INT(((LO) + (((double)((double)((((SEED) * ((int)((((short)(HI)) - (LO))))))) / (double)((float)(32767)))))));
                                                                //     37  %end
#line 37 "regression-compile-tmp/random.imp"
} // End of block RANDOMINT at level 1
                                                                //     38  
                                                                //     39  !%list
                                                                //     40  %endoffile
#line 40 "regression-compile-tmp/random.imp"
// End of file
