On 05/04/17 17:55, Bart wrote:
> http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Random
>
> "random returns a random number between 0 and abs(num-1)"
>
> IIUC, then Random() shoud always return a positive number.
>
Mmm, I don't think so:
For y := Random(num);
the unsigned value of 'y' will
Usualy "non-negative", not positive !
Cheers, Ched'
Le 05.04.2017 à 16:55, Bart a écrit :
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Random
"random returns a random number between 0 and abs(num-1)"
IIUC, then Random() shoud always return a positive number.
Bart
http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Random
"random returns a random number between 0 and abs(num-1)"
IIUC, then Random() shoud always return a positive number.
Bart
___
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
Fun fact: TP's random used an unsigned parameter (word), so no ambiguity there.
Random (function)
--
Returns a random number.
Declaration:
function Random [ ( Range: Word) ]: < Same type as parameter >;
Bart
___
fpc-pascal maillist
On 4/5/17, Santiago A. wrote:
> random(-10)
> will output numbres -9..0
That was not realy the question.
The question is wether the documentation is wrong, or the
implementation or neither.
B.t.w. Delphi7 gives me:
Random(-10) = -776108169
Random(-10) = 244426112
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;
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
>