Il 05/04/2017 18:09, Bart ha scritto:
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.


My scant knowledge of English leads me to believe that the sentence should be rephrased in order to cover the negative numbers case:

either:

   Random return a random number with the same sign of L, and whose
   absolute value is larger or equal to zero and strictly less than the
   absolute value of L.

or:

   Random return a random number in the range 0 (included) to L (excluded).

Just my 2c.

Giuliano

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

Reply via email to