[fpc-pascal] Bug in documentation for Random?

Giuliano Colla giuliano.colla at fastwebnet.it
Wed Apr 5 18:46:38 CEST 2017


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170405/5742de58/attachment.html>


More information about the fpc-pascal mailing list