Modulo Operator %%

kdex kdex at kdex.de
Mon Aug 12 22:05:49 UTC 2019


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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190813/d6aa25b6/attachment.sig>


More information about the es-discuss mailing list