[fpc-pascal] Bug in documentation for Random?

Lukasz Sokol el.es.cr at gmail.com
Thu Apr 6 10:00:34 CEST 2017


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.





More information about the fpc-pascal mailing list