[fpc-devel] Different results of random(int32) and random(int64) for negative limit value
Martin Schreiber
mse00000 at gmail.com
Sat May 20 14:36:02 CEST 2017
Hi,
FPC fixes_3_0, Linux X86:
"
var
i1: int32;
begin
for i1:= 0 to 5 do begin
writeln(random(int32(-16)));
end;
writeln('*************');
for i1:= 0 to 5 do begin
writeln(random(int64(-16)));
end;
end;
"
produces
"
-9
-9
-11
-13
-10
-13
*************
3
9
5
4
6
8
"
Is this intended? If not, which one is correct?
https://www.freepascal.org/docs-html/current/rtl/system/random.html
states for 32 and 64 bit
"
Random returns a random number larger or equal to 0 and strictly less than L.
"
which raises the question, what means "less"?
Martin
More information about the fpc-devel
mailing list