[swift-evolution] 'Random' Improvements

David Rönnqvist david.ronnqvist at gmail.com
Wed Apr 5 04:26:54 CDT 2017


I’m just going to mention that there was a tiny discussion about Random in early March (only five messages, all linked to below).

That thread discussed the different expectations/understandings of “random”.  

Regards,
David

https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170227/033473.html <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170227/033473.html>
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170227/033474.html <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170227/033474.html>
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170227/033477.html <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170227/033477.html>
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170227/033478.html <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170227/033478.html>
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170227/033482.html <https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170227/033482.html>



> On 3 Apr 2017, at 21:24, Pedro Ferreira via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Thanks for the correction. 
> 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.
> 
> On Mon, Apr 3, 2017 at 6:53 PM, Peter Dillinger <Peter.Dillinger at synopsys.com <mailto:Peter.Dillinger at synopsys.com>> wrote:
> > 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 <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 <http://www.synopsys.com/software>
>  
> 
>  
> 
>  
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170405/99df696b/attachment.html>


More information about the swift-evolution mailing list