[fpc-pascal] Bug in documentation for Random?

Santiago A. svaa at ciberpiula.net
Wed Apr 5 15:35:51 CEST 2017


El 05/04/2017 a las 18:09, Bart escribió:
> http://www.freepascal.org/docs-html/current/rtl/system/random.html
>
> "Random returns a random number larger or equal to 0 and strictly less than L"
>
> However random(a negative number) returns a number <= 0 and > L
>
>
> program r;
> begin
>   randomize;
>   writeln('Random(-10) = ',Random(-10));
> end.
>
> C:\Users\Bart\LazarusProjecten>test
> random(-10) = -1
> C:\Users\Bart\LazarusProjecten>test
> random(-10) = -4
>
> Maybe my understanding of English ("strictly less than") is not
> correct, so I ask here before posting as a bugreport.

I've never used negative values, so this is just a guess:
random(+10)
will output numbres 0..9

random(-10)
will output numbres -9..0

so, it is equivalent to
-random(10)

-- 
Saludos

Santi
svaa at ciberpiula.net




More information about the fpc-pascal mailing list