mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-02 13:10:28 +02:00
* compilation of tests on 32 bit targets fixed, using while loops so keeping the type sizes
git-svn-id: trunk@42526 -
This commit is contained in:
parent
b3ed34592f
commit
3ef319c0b0
@ -4,8 +4,8 @@ program random_test;
|
|||||||
const
|
const
|
||||||
l: UInt64 = 6148914691236517205;
|
l: UInt64 = 6148914691236517205;
|
||||||
var
|
var
|
||||||
s,n: UInt32;
|
s,n: UInt64;
|
||||||
i,j: UInt32;
|
i,j: UInt64;
|
||||||
begin
|
begin
|
||||||
WriteLn('Experiment:', LineEnding);
|
WriteLn('Experiment:', LineEnding);
|
||||||
WriteLn(' Draw a natural number r from the intervall [0,l-1] and');
|
WriteLn(' Draw a natural number r from the intervall [0,l-1] and');
|
||||||
@ -16,14 +16,20 @@ begin
|
|||||||
|
|
||||||
WriteLn('Input size n':16, 'Observed ratio s/n':30);
|
WriteLn('Input size n':16, 'Observed ratio s/n':30);
|
||||||
l := 6148914691236517205;
|
l := 6148914691236517205;
|
||||||
for j := 4 to 18 do
|
j := 4;
|
||||||
|
while j <= 18 do
|
||||||
begin
|
begin
|
||||||
n := (Int32(1) shl j);
|
n := (UInt64(1) shl j);
|
||||||
s := 0;
|
s := 0;
|
||||||
for i := 0 to n-1 do
|
i := 0;
|
||||||
if Random(Int64(l)) < l div 2 then
|
while i <= n-1 do
|
||||||
Inc(s);
|
begin
|
||||||
|
if Random(Int64(l)) < l div 2 then
|
||||||
|
Inc(s);
|
||||||
|
Inc(i);
|
||||||
|
end;
|
||||||
WriteLn( (UInt64(1) shl j):16, s/n:30);
|
WriteLn( (UInt64(1) shl j):16, s/n:30);
|
||||||
|
Inc(j);
|
||||||
end;
|
end;
|
||||||
if abs(0.5-(s/n))>0.1 then
|
if abs(0.5-(s/n))>0.1 then
|
||||||
halt(1);
|
halt(1);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
var
|
var
|
||||||
rand, val: int64;
|
i, rand, val: int64;
|
||||||
i: int32;
|
|
||||||
begin
|
begin
|
||||||
rand:=-5;
|
rand:=-5;
|
||||||
for i:=1 to 10000 do
|
i:=1;
|
||||||
|
while i<=10000 do
|
||||||
begin
|
begin
|
||||||
val:=random(rand);
|
val:=random(rand);
|
||||||
if (val<-5) or (val>0) then
|
if (val<-5) or (val>0) then
|
||||||
@ -11,5 +11,6 @@ begin
|
|||||||
writeln('error: ', val);
|
writeln('error: ', val);
|
||||||
halt(1);
|
halt(1);
|
||||||
end;
|
end;
|
||||||
|
Inc(i);
|
||||||
end;
|
end;
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user