<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>I wouldn't mind if the standard `%` operator worked like this and there would be another top-level function `mod(p, q)` that worked like `%` in C. The only times that I've ever needed the modulo operation (<a href="https://en.wikipedia.org/wiki/Modulo_operation">https://en.wikipedia.org/wiki/Modulo_operation</a>) to behave <i>some way</i> on negative values it's always been the suggested remainder-of-flooring-division way.</div><div><br></div><div>On the other hand, there's a performance penalty (avoidable by using the other mod operation), so I can understand if not everyone agrees.</div><div><br></div><div>And like Steve said below, then we'll need a flooring division function (or operator) as well. And a flooring `(f, r) = divmod(p, q)` too, I suppose.</div><div><br></div><div>In any case, I'm probably +1 if a well-thought proposal is brought to the table.</div><div><br></div><div>— Pyry</div><div><br>Adam Nemecek wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">Would you want to make this a function? Or an operator but a different one?</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 23, 2016 at 7:30 AM, Stephen Canon <span dir="ltr"><<a href="mailto:scanon@apple.com" target="_blank">scanon@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>I’m not really sold on the `%%` spelling, but I think the operation itself is worth exposing. This is the remainder of a “flooring” division (as opposed to the C-family “truncating” division[1]). If we do provide it, we should also provide the accompanying divide operation.</div><div><br></div><div>– Steve</div><div><br></div><div>[1] there are several other ways to define division beyond these two: remainder is always positive, remainder is closest to zero, etc. Truncating and flooring division are the most common by a wide margin, however.</div></div></blockquote></div></div></div></blockquote></body></html>