-
Notifications
You must be signed in to change notification settings - Fork 669
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(−0, +∞) and mod(+0, −∞) not handled correctly #4723
Comments
But really, this shows why If you just make |
It definitely shouldn't be infinity. Replace ∞ with a very large finite number, and the answer is definitely just +0. It could be NaN, but the general policy is that we define the behavior for ∞ arguments to be the limit as the argument approaches ∞, if the limit exists; it's only NaN if there's no limit. |
Using limits, shouldn't we have
instead of NaN? However, I'd expect But I guess not having that property can be attributed to precision problems. Like
even though |
For example, cotpi(x) should equal cotpi(mod(x, 1)), but while cotpi(-0) = cotpi(1) = –∞, cotpi(0) = ∞ But mod(x, ∞) for any x is nonsensical either way; it implies dividing by ∞, taking the floor, multiplying the resulting quotient by ∞, and then subtracting. We get ∞ · 0 in the middle of that process. |
@jrus You are saying Unlike What's cotpi?
Not necessarily. What If
|
That floating point arithmetic is not the same as real-number arithmetic is sort of my point. It tends to break down at edge cases. I think it’s fine to make
Sorry I said “divide by 0”, what I meant was “multiply 0 by ∞”, as I fixed slightly afterward. cotpi(x) = cot(πx), the cotangent of π times the argument. Trigonometric functions with a factor of π included can save some grief in many practical situations, since π cannot be exactly represented in floating point. A clearer way to state my original point is: I can’t think of any practical computation where a person would ever end up with If you define it via a limiting argument, then clearly mod(x, ∞) has a limit of x for any x ≥ 0 and a limit of ∞ for any x < 0. But I think it would be better to just let mod(x, ∞) = NaN regardless. |
Fair enough, I had only seen it with integers, but I thought I could generalize it.
Oh I didn't know this notation. I see your point, but floating point numbers don't have a
Sure, I don't think people will use an explicit ∞, but possibly they will use some calculation which may end up being ∞ in certain cases.
NaN is reasonable for negative x, but not that sure about positive x. Intuitively I would expect |
Re-reviewing this, I think I agree that the current behavior (
I'm relatively ambivalent between the two, but weakly prefer the second; a process which approaches -0 is doing so from the negative side, where all the similar non-zero negative values produce NaN, and so I think it's slightly better to be consistent there. Thoughts? |
Both approaches can be reasonable, no strong opinion. |
From https://drafts.csswg.org/css-values-4/#round-infinities
This means that
mod(−0, +∞) = −0
andmod(+0, −∞) = +0
.However, the returned value is supposed to be between zero and B, with
So we should have
mod(−0, +∞) = +0
andmod(+0, −∞) = −0
.The text was updated successfully, but these errors were encountered: