For syntactic precedent, CoffeeScript and R both have `%%` for a modulus returning the sign of the divisor, where `a %% b` is equivalent to `(a % b + b) % b`. So JS wouldn't be the first here.
Most languages Wikipedia lists in their comparison (https://en.wikipedia.org/wiki/Modulo_operation) use a function for this kind of modulus operation, not an operator. That itself seems worth noting. ----- Isiah Meadows [email protected] www.isiahmeadows.com On Tue, Aug 13, 2019 at 10:27 AM Michael Haufe <[email protected]> wrote: > > I would prefer the syntax be ‘a mod b’ consistent with my wishlist item: > > > > <https://esdiscuss.org/topic/new-operator> > > <https://esdiscuss.org/topic/still-waiting-for-integer-division> > > > > In regards to semantics: > > > > <https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/divmodnote.pdf> > > > > > > > > From: es-discuss <[email protected]> On Behalf Of Cyril Auburtin > Sent: Tuesday, August 13, 2019 5:07 AM > Cc: es-discuss <[email protected]> > Subject: Re: Modulo Operator %% > > > > agreed, let's make a proposal > > > > On Tue, Aug 13, 2019 at 12:06 AM kdex <[email protected]> wrote: > > I would welcome such an operator as well. I find myself implementing a `mod` > function from time to time, expressing it in terms of the remainder operator. > > As for syntax, I don't see `%%` posing any syntactical ambiguities, so I'll > second it. > > On Monday, August 12, 2019 10:00:09 PM CEST Matthew Morgan wrote: > > JS needs a modulo operator. It currently has the remainder operator `%` > > which works in most cases except for negative values. I believe the the > > `%%` would work great and be easy to remember. > > > > let x = (-13) %% 64; > > is equivalent to > > let x = ((-13 % 64) + 64) % > > 64;_______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

