home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
UTILITYS
/
RANDOM.ARC
/
RANDOM.LST
< prev
Wrap
File List
|
1990-07-21
|
896b
|
38 lines
LISTING 1
program...
var
x, y, z: integer; { global seeds }
. . .
funtion random: real;
var
temp: real;
begin
{ first generator }
x := 171 * (x mod 177) - 2 * (x div 177);
if x < 0 then
x := x + 30269;
{ second generator }
y :=172 * (y mod 176) - 35* (y div 176);
if y < 0 then
y :=y + 30307
{ third generator }
z := 170 * (z mod 178) - 63* (z div 178);
if z < 0 then
z := z + 30323
{ combine to give function value }
temp := x/30269.0 + y/30307.0 + z/30323.0;
random := temp - trunc(temp)
end;
...
begin
{ initializse seeds. For production runs, different
values (between 1 and 30000) should be used each time,
preferably by some automatic method such as from date
and time readings if available }
x :=1; y := 10000; z:= 3000;
...
end