<div dir="ltr">Thanks for the correction. <div>I guess that helps my point, its easy to get this sort of thing wrong, so it would be a good candidate for being included in the standard library.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 3, 2017 at 6:53 PM, Peter Dillinger <span dir="ltr"><<a href="mailto:Peter.Dillinger@synopsys.com" target="_blank">Peter.Dillinger@synopsys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div class="m_-6315270966743277810WordSection1"><span class="">
<p class="m_-6315270966743277810MsoPlainText">> func getRandom(_ min: Int, _ max: Int) -> Int {<u></u><u></u></p>
<p class="m_-6315270966743277810MsoPlainText">> let diff = max - min + 1<u></u><u></u></p>
<p class="m_-6315270966743277810MsoPlainText">> <u></u><u></u></p>
<p class="m_-6315270966743277810MsoPlainText">> #if os(Linux)<u></u><u></u></p>
<p class="m_-6315270966743277810MsoPlainText">> return min + Int(random() % diff)<u></u><u></u></p>
</span><p class="m_-6315270966743277810MsoPlainText">> ...<u></u><u></u></p>
<p class="m_-6315270966743277810MsoPlainText"><u></u> <u></u></p>
<p class="m_-6315270966743277810MsoPlainText">Implementation detail: non-uniformity mistakes of the past should not be repeated.
<a href="http://stackoverflow.com/a/6852396/454544" target="_blank">http://stackoverflow.com/a/<wbr>6852396/454544</a> (Timed out on finding a better reference.)<u></u><u></u></p>
<p class="m_-6315270966743277810MsoPlainText"><u></u> <u></u></p>
<p class="m_-6315270966743277810MsoPlainText">-- <u></u><u></u></p>
<p class="m_-6315270966743277810MsoPlainText">Peter Dillinger, Ph.D.<u></u><u></u></p>
<p class="m_-6315270966743277810MsoPlainText">Software Engineering Manager, Coverity Analysis, Software Integrity Group | Synopsys<u></u><u></u></p>
<p class="m_-6315270966743277810MsoPlainText"><a href="http://www.synopsys.com/software" target="_blank">www.synopsys.com/software</a><u></u><u></u></p>
<p class="m_-6315270966743277810MsoPlainText"><u></u> <u></u></p>
<p class="m_-6315270966743277810MsoPlainText"> <u></u><u></u></p>
<p class="m_-6315270966743277810MsoPlainText"><u></u> <u></u></p>
</div>
</div>
</blockquote></div><br></div>