Bug in documentation for Random?
Original Reporter info from Mantis: Bart @flyingsheep
-
Reporter name: Bart Broersma
Original Reporter info from Mantis: Bart @flyingsheep
- Reporter name: Bart Broersma
Description:
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
Steps to reproduce:
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
Additional information:
Delphi documentation basically is the same (http://docwiki.embarcadero.com/Libraries/Berlin/en/System.Random) and the behaviour with neagtive inut is rather irratic
(
On Delphi 7:
Random(-10) = -776108169
Random(-10) = 244426112
Random(-10) = -1774796928
Random(-10) = 1443026331
Random(-10) = -919853036
Random(-10) = -747947900
Random(-10) = -1767321924
Random(-10) = -2114448955
Random(-10) = 1499268340
Random(-10) = -1658783534
)
Mantis conversion info:
- Mantis ID: 31642
- OS: Windows
- OS Build: Win7
- Build: 3.0.2
- Platform: i386
- Version: 3.0.1
- Fixed in revision: 1649 (#cb3fc308)