Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define remainder (and/or modulo) #621

Open
domenic opened this issue Sep 28, 2023 · 2 comments
Open

Define remainder (and/or modulo) #621

domenic opened this issue Sep 28, 2023 · 2 comments

Comments

@domenic
Copy link
Member

domenic commented Sep 28, 2023

What is the issue with the Infra Standard?

whatwg/streams#1145 wants to use the equivalent of JavaScript's % operator. This is surprisingly subtle because of the difference between modulo and remainder. See discussion in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Remainder .

I suggest the terminology "the [remainder after dividing] |dividend| by |divisor|".

I also suggest that we add a clear note about how this maps to some language's % operator (JavaScript, C, C++) but mismatches others (Python, Perl).

There might also be some subtlety here about rounding toward 0 vs. not?

We should probably delegate the actual definition to https://tc39.es/ecma262/#sec-numeric-types-number-remainder , although I guess ideally we'd figure out #87 first.

/cc @MattiasBuelens

@annevk
Copy link
Member

annevk commented Sep 28, 2023

See also https://encoding.spec.whatwg.org/#terminology for some (potentially different) precedent.

@MattiasBuelens
Copy link

whatwg/streams#1145 wants to use the equivalent of JavaScript's % operator. This is surprisingly subtle because of the difference between modulo and remainder.

For Streams, the difference doesn't matter, since we only ever have positive dividends and divisors. From a quick look at Encoding, I think the same applies there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants