[swift-evolution] 'Random' Improvements
Peter Dillinger
Peter.Dillinger at synopsys.com
Mon Apr 3 12:53:57 CDT 2017
> func getRandom(_ min: Int, _ max: Int) -> Int {
> let diff = max - min + 1
>
> #if os(Linux)
> return min + Int(random() % diff)
> ...
Implementation detail: non-uniformity mistakes of the past should not be repeated. http://stackoverflow.com/a/6852396/454544 (Timed out on finding a better reference.)
--
Peter Dillinger, Ph.D.
Software Engineering Manager, Coverity Analysis, Software Integrity Group | Synopsys
www.synopsys.com/software
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170403/b12433ed/attachment.html>
More information about the swift-evolution
mailing list