-
Notifications
You must be signed in to change notification settings - Fork 645
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
[css-values] mod() isn't needed #6637
Comments
The problem is that |
It's named that because that's what the operation it's performing is called, which is why CSS calls the function implementing that behavior A number of languages have one behavior or the other, and give the operation one name or the other; it's pretty inconsistent across programming languages. We did a survey of languages and mathematical resources, and figured that remainder/modulus was, overall, the most accepted pair of names.
I'm not sure what you mean - are you referring to the note at the end that explains how one can do
As Oriol said (and the spec explains, in the note titled "Why Should I Choose mod() vs rem()?"), the "modulus" operation is the form of the operation that's taught in math classes when learning about modular arithmetic, and is generally more useful and intuitive to people. JS's use of the remainder operation for Wikipedia goes into (as usual for math articles) too much detail about this, but at least the "Common Pitfalls" section is short and sweet, illustrating the issue we're trying to avoid by recommending people generally use |
Assuming that this response was sufficient, so closing. |
We in WebKit have received feedback that having both mod() and rem() is confusing. This area is already confusing due to the mod operator
%
being named remainder in javascript, and by adding a mod() function (which shares a name with the name of an operator when it doesn't share its behavior), it complicates things even further. Also, the mod function that the spec dictates (https://drafts.csswg.org/css-values-4/#round-func) is a weird combination of multiple math functions that I don't believe exists in any language. When the input arguments have the same sign, mod() behaves as the C function fmod, and when they have different signs, it behaves as the C function remainder. There is no need to be more expressive than javascript, which only has the%
operator, so there is no reason to have any additional functions for this beyond rem(). At the very least, mod() should be modeled after an existing math function, such as C's remainder, but it would be a better solution to remove mod() entirely to avoid confusion.The text was updated successfully, but these errors were encountered: