[fpc-pascal] Repeat result in random
Tony
afmcc at btinternet.com
Sat Nov 26 16:25:54 CET 2016
Here is a short program to print 10 random numbers:
program testrandom;
var
i: Integer;
begin
Randomize;
for i := 1 to 10 do
WriteLn(Random);
end.
If I compile and run this program using FPC 3.0.0 on Ubuntu 16.04
x86_64 I get the following:
$ /usr/lib/fpc/3.0.0/ppcx64 testrandom
Free Pascal Compiler version 3.0.0+dfsg-2 [2016/01/28] for x86_64
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling testrandom.pp
Linking testrandom
/usr/bin/ld.bfd: warning: link.res contains output sections; did you
forget -T? 14 lines compiled, 0.1 sec
$ ./testrandom
9.34558931970968842506E-0001
7.37956080120056867599E-0001
9.57959748106077313423E-0001
8.50854847114533185959E-0001
1.81509985821321606636E-0001
6.14049500785768032074E-0001
9.82306003570556640625E-0002
3.28659117221832275391E-0001
3.45761539181694388390E-0001
6.87781326007097959518E-0001
All well and good. However, if I compile using FPC 3.1.1 from svn I
get the following:
$ /usr/local/lib/fpc/3.1.1/ppcx64 testrandom
Free Pascal Compiler version 3.1.1 [2016/11/26] for x86_64
Copyright (c) 1993-2016 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling testrandom.pp
Linking testrandom
14 lines compiled, 0.1 sec
$ ./testrandom
3.31493919249624013901E-0001
3.31493919249624013901E-0001
5.16012400388717651367E-0001
2.02815276337787508965E-0001
5.62052882276475429535E-0001
9.15243660099804401398E-0001
7.51263931626453995705E-0001
9.20306718209758400917E-0001
9.01774314232170581818E-0001
7.98331435071304440498E-0001
The first two random numbers are always equal.
Am I missing something or is this a bug in 3.1.1?
Tony
More information about the fpc-pascal
mailing list