[fpc-pascal] Why is Random(255) some 529x slower compared to Delphi 7?

Jürgen Hestermann juergen.hestermann at gmx.de
Fri Dec 9 07:27:46 CET 2011



Reimar Grabowski schrieb:
> The parameter should default to FALSE to not break existing code relying on FPCs random function 
And what about existing code coming from Delphi/Turbo Pascal? This was a 
strong argument in the past for doing even crap coding.



> As the fast random function then has to be called with random(x, true) 
I think this would be the best solution: Add an additional parameter to 
random() so that existing code would stop on compiling and the user has 
to look up the help to see what this additional parameter means. Then 
everybody is forced to choose the version that fits for his needs.

But having the same function doing something different (or at a 
magnitude different speed) is the wrong way IMO. Just imagine that 
divisions suddenly need 500 times the time because the last digit was 
inaccurate or so. In many cases the error is not relevant in your 
programs but the speed penalty surely would.



More information about the fpc-pascal mailing list