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
s...@ciberpiula.net

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to