[fpc-devel] Different results of random(int32) and random(int64) for negative limit value

Mark Morgan Lloyd markMLl.fpc-devel at telemetry.co.uk
Sat May 20 15:29:32 CEST 2017

On 20/05/17 13:00, Martin Schreiber wrote:
> 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*************395468"Is this intended? If not, which one is correct?https://www.freepascal.org/docs-html/current/rtl/system/random.htmlstates 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"?

What does it do if the parameter is +ve? Note 

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the fpc-devel mailing list