瀏覽代碼

* compilation of tests on 32 bit targets fixed, using while loops so keeping the type sizes

git-svn-id: trunk@42526 -
florian 6 年之前
父節點
當前提交
3ef319c0b0
共有 2 個文件被更改,包括 17 次插入10 次删除
  1. 13 7
      tests/webtbs/tw35878.pp
  2. 4 3
      tests/webtbs/tw35878a.pp

+ 13 - 7
tests/webtbs/tw35878.pp

@@ -4,8 +4,8 @@ program random_test;
 const
    l: UInt64 = 6148914691236517205;
 var
-   s,n: UInt32;
-   i,j: UInt32;
+   s,n: UInt64;
+   i,j: UInt64;
 begin
   WriteLn('Experiment:', LineEnding);
   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);
   l := 6148914691236517205;
-  for j := 4 to 18 do
+  j := 4;
+  while j <= 18 do
   begin
-    n := (Int32(1) shl j);
+    n := (UInt64(1) shl j);
     s := 0;
-    for i := 0 to n-1 do
-      if Random(Int64(l)) < l div 2 then
-        Inc(s);
+    i := 0;
+    while i <= n-1 do
+      begin
+        if Random(Int64(l)) < l div 2 then
+          Inc(s);
+        Inc(i);
+      end;
     WriteLn( (UInt64(1) shl j):16, s/n:30);
+    Inc(j);
   end;
   if abs(0.5-(s/n))>0.1 then
     halt(1);

+ 4 - 3
tests/webtbs/tw35878a.pp

@@ -1,9 +1,9 @@
 var
-  rand, val: int64;
-  i: int32;
+  i, rand, val: int64;
 begin
   rand:=-5;
-  for i:=1 to 10000 do
+  i:=1;
+  while i<=10000 do
     begin
       val:=random(rand);
       if (val<-5) or (val>0) then
@@ -11,5 +11,6 @@ begin
           writeln('error: ', val);
           halt(1);
         end;
+      Inc(i);
     end;
 end.