<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 18, 2015, at 3:40 PM, August Joki 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 class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; 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;"><br class="Apple-interchange-newline"><br class="Apple-interchange-newline"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 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; float: none; display: inline !important;">-August</span></div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; 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;"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; 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;" class=""><blockquote type="cite" class=""><div class="">On 18 Dec, 2015, at 15:31, Kevin Ballard 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 class=""><div class="">On Fri, Dec 18, 2015, at 03:04 PM, Chris Lattner via swift-evolution wrote:<br class=""></div><blockquote type="cite" class=""><div class=""> </div><div class=""><blockquote type="cite" class=""><div class="">On Dec 18, 2015, at 3:03 PM, Stephen Canon <<a href="mailto:scanon@apple.com" class="">scanon@apple.com</a>> wrote:<br class=""></div><div class=""> </div><div class=""><div class="" style="word-wrap: break-word; -webkit-line-break: after-white-space;"><div class=""> </div><div class=""><blockquote type="cite" class=""><div class="">On Dec 18, 2015, at 5:57 PM, Chris Lattner <<a href="mailto:clattner@apple.com" class="">clattner@apple.com</a>> wrote:<br class=""></div><div class=""> </div><div class=""><div class="" style="word-wrap: break-word; -webkit-line-break: after-white-space;"><div class="">On Dec 18, 2015, at 1:12 PM, Stephen Canon via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""></div><div class=""><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-line-break: after-white-space;"><div class="">Hi everybody —<br class=""></div><div class=""> </div><div class="">I’d like to propose removing the “%” operator for floating-point types.<br class=""></div></div></div></blockquote><div class=""> </div><div class="">I support removing this - it is actively harmful for a surprising operation like this to have such short and inviting syntax. As asked downthread, have you given any thought into whether a Decimal type would support this operation?<br class=""></div></div></div></div></blockquote><div class=""> </div></div><div class="">The same concerns apply to decimal. It makes sense to have the operation (for both binary and decimal floating-point) as “Type.remainder(a,b)” or a free function like "remainder(a, b)”, but I would prefer not to use the operator “%” for it because it behaves very differently from integer %, and in ways that are not at all obvious to most users.<br class=""></div></div></div></blockquote><div class=""> </div></div><div class="">Great, I’d prefer decimal and the float types to have a consistent interface where possible. +1 from me on the proposal.<br class=""></div></blockquote><div class=""> </div><div class="">Agreed. +1 from me too. The `10.0 % 0.1` behavior is sufficiently surprising that I think that justifies removal by itself.<br class=""></div><div class=""> </div><div class="">I'm also in favor of adding mod and remainder as instance methods of the floating point types, e.g. `10.0.mod(0.1)` (as opposed to static methods or free functions).<br class=""></div></div></div></blockquote>Shouldn’t that be added to any Arithmetic type?<br class=""></div></div></blockquote><div><br class=""></div>We don't offer protocols that abstract over both integer and float arithmetic. They behave differently, and require different algorithms and interfaces. Floating-point types gaining a `mod` member does not necessarily mean integer types should get the same.</div><div><br class=""></div><div>-Joe<br class=""></div></body></html>