<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">That’s the default rounding mode for arithmetic operations, but these “roundToIntegral” operations are orthogonal from the dynamic rounding mode or its default.</div><div class=""><br class=""></div><div class="">Schoolbook rounding (ties away from zero) is both most people’s naive expectation, and also matches the behavior of the C/C++ round( ) function. Principle of least surprise makes it the default choice.</div><div class=""><br class=""></div><div class="">– Steve</div><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 30, 2016, at 4:52 PM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">A question, perhaps Stephen's to answer: apparently IEEE754 defaults to what we're calling `toNearestOrEven`? Should Swift be using that as the default as well?<div class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Jun 29, 2016 at 7:41 PM, Karl Wagner <span dir="ltr" class=""><<a href="mailto:razielim@gmail.com" target="_blank" class="">razielim@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">OK I’ve incorporated those small things and submitted it for review. We’ve had an initial discussion, incorporated all the feedback, so I think it’s met the bar for a PR 👍<div class=""><br class=""></div><div class=""><a href="https://github.com/apple/swift-evolution/pull/394" target="_blank" class="">https://github.com/apple/swift-evolution/pull/394</a></div><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">Karl</div></font></span><div class=""><div class="h5"><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 29 Jun 2016, at 20:20, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">On Wed, Jun 29, 2016 at 1:07 PM, Stephen Canon<span class=""> </span><span dir="ltr" class=""><<a href="mailto:scanon@apple.com" target="_blank" class="">scanon@apple.com</a>></span><span class=""> </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-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><span class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jun 29, 2016, at 2:06 PM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">On Wed, Jun 29, 2016 at 12:12 PM, Stephen Canon via swift-evolution<span class=""> </span><span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span><span class=""> </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-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><span class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jun 29, 2016, at 1:10 PM, Matthew Johnson <<a href="mailto:matthew@anandabits.com" target="_blank" class="">matthew@anandabits.com</a>> wrote:</div><br class=""><div class=""><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="">My criticism of the '</span><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgba(255,255,255,0)" class="">toNearestOrGreatest' still stands though. I think this name is misleading given the stated semantics. The name indicates "greater value" not "greater magnitude" which are opposites in the case of negative numbers.</span><br class=""></div></blockquote></div><br class=""></span><div class="">Yup, I agree. I think I originally suggested `toNearestTiesAway`. I’m not tied to that name specifically, but we should be clear that ties go away from zero, not up.</div></div></blockquote><div class=""><br class=""></div><div class="">Agreed; `toNearestOrAwayFromZero` is the most accurate and consistent description.</div></div></div></div></div></blockquote><br class=""></div></span><div class="">Worth noting that since this is the defaulted behavior, we can get away with a wordy description.</div></div></blockquote><div class=""><br class=""></div><div class="">This is really picking nits, but the most common behavior would be best as the first enum case, no? Maybe go roughly from most-value-preserving to least-value-preserving, like so:</div><div class=""><br class=""></div><div class="">`enum RoundingRule { case toNearestOrAwayFromZero, toNearestOrEven, up, down, towardZero }`</div><div class=""><br class=""></div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><br class=""></div><div class="">– Steve</div></div></blockquote></div></div></div></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div></div></div>
</div></blockquote></div><br class=""></body></html>