<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Not a floating point expert, but are you sure this works? I have a feeling this would lead to a distribution that’s not uniform.<div class=""><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Saagar Jha</div>
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On Jan 10, 2018, at 14:07, Jens Persson via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">On Tue, Jan 9, 2018 at 10:07 PM, Jonathan Hull via swift-evolution <span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span> wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><br class=""></div><div class=""><div class="">One additional question. How do you ergonomically get a Double which doesn’t have a range, but also isn’t NaN?</div><div class=""><div class="gmail-h5"><div class=""><br class=""></div></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Assuming you are ok with signed zero and infinities and "strange" bias as result of IEEE 754:</div><div class=""><div class=""><br class=""></div><div class="">func randomNonNanDouble<R: RandomNumberGenerator>(using generator: R) -> Double {</div><div class=""> while true {</div><div class=""> let rndUInt64 = generator.next()</div><div class=""> let rndDouble = Double(bitPattern: rndUInt64)</div><div class=""> if rndDouble != Double.nan { return rndDouble }</div><div class=""> }</div><div class="">}<br class=""></div></div><div class=""><br class=""></div><div class="">/Jens</div><div class=""><br class=""></div></div></div></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>