<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Jonas, sorry for the late response:</p>
<p>The implementation is <u><b>not </b></u>undefined for negative
values,<u> unless you say that you define it as undefined</u>.</p>
<p>Because you seem to have implemented it or most of it.<br>
</p>
<p>It renders a mathematical comparable distribution in the negative
to the positive values.</p>
<p>In both Turbo Pascal as in Delphi and because they use a
different algorithm and made an implementation error as well, the
negative values are indeed not defined. But that's because of the
algorithm and because of the implementation by Borland (yes, it
stems from Borland times).</p>
<p>The Mersenne Twister we use is also valid for negative values and
if you want I can send you the mathematical proof.</p>
<p>I already made the LCG in Delphi compatible mode available on the
wiki and that implementation differs in so far as that it corrects
the "undefined for negative values" for that algorithm too. It is
100% compatible for the Delphi documented range, btw.</p>
<p>I am busy evaluating important Random implementions for different
languages, so an FPC library is available for data that is
generated in a different language and relies on a particular PRNG.</p>
<p>Also note that the output of the current random is strictly valid
for 32 bit only.</p>
<p>In my code I already added a 64 bit version.<br>
</p>
<p>Regards,</p>
<p>Thaddy<br>
</p>
<p><br>
</p>
<p><br>
</p>
<br>
<div class="moz-cite-prefix">On 5/20/2017 2:57 PM, Jonas Maebe
wrote:<br>
</div>
<blockquote
cite="mid:79bb1be3-3814-9ce1-ff12-fb7f60829c92@freepascal.org"
type="cite">On 20/05/17 14:36, Martin Schreiber wrote:
<br>
<blockquote type="cite">Is this intended? If not, which one is
correct?
<br>
</blockquote>
<br>
random(x) is undefined for negative parameters. It should have had
an unsigned parameter, like in Turbo Pascal (where it is word).
Delphi defines it as always returning a positive value, but I
don't know what happens if you pass a negative parameter there.
<br>
<br>
<br>
Jonas
<br>
_______________________________________________
<br>
fpc-devel maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel</a>
<br>
</blockquote>
<br>
</body>
</html>