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 will between 0 and abs(num-1) - inclusive,
but then, the value returned keeps the sign of num;

(this as per FPC implementation)

I like Giuliano's definition, it is brief and beautiful:

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

(maybe with a similarly brief and concise remark: 'regardless of the sign of L'


> Bart

-L.


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

Reply via email to