-
Notifications
You must be signed in to change notification settings - Fork 644
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-syntax-3][css-values-4] Add informative note about tokenization of negative 0 #7472
Comments
Writing
Note that I didn't remove anything in that commit, I just switched from a misleading way to writing negative zero ( I'm somewhat loathe to put an explicit note or example about this into the spec, because it's a corner case that matters to approximately zero authors. For implementors, the right behavior just falls out if they follow the specs.
I didn't write the algorithm with any regard to JS's algorithm, but I expect they're probably very similar? I know that there's at least one difference, tho - (If implementations are indeed producing a negative zero from |
I was referring to this part: Note: that, outside of [=math functions=], ''-0'' just produces a "standard" zero, identical to ''0''-- CSS as a whole doesn't recognize the concept of signed zeros. Without this note, if CSS claims that it obeys IEE754 semantics for dividing a positive value by zero produces +∞, I can not know why
... but I'm fine with this position, ok.
For a JS implementation of conversion from string to number, following the spec does not help. I have to return unsigned
I think there is no other difference. From reading the JS spec, I can only note that |
Actually, upon review you're right - the "convert a string to a number" algorithm will, upon seeing So that's a bug on my part and should be fixed. |
I came back to this issue after a while and I am not entirely sure of your intention, because of this comment:
It is valid CSS. I assume you do not want to make it invalid, but to remove its sign in convert a string to number, right? Basically: 2. An integer part: zero or more digits. If there is at least one digit,
let i be the number formed by interpreting the digits as a base-10 integer;
otherwise, let i be the number 0.
+ If i is the number 0, set s to 1. So Alternatively, -0; // -0
(-0).toString(); // '0' But I may be missing the historical reasons for CSS not recognizing the sign of 0. |
Right, and that was the problem - I was trying to refer to a negative zero, but
Right. Like I said, "This is why all the examples in V&U that talk about negative zero produce it via a calculation", rather than writing |
Fixed in 3560680, isn't it? Edit: nope, sorry, it does not. |
Right, that commit's irrelevant to this issue. |
fixes #1 refs w3c/csswg-drafts#7472
fixes #1 refs w3c/csswg-drafts#7472
I cannot tell which behavior is "right", if there is one, and I cannot think of an example for which it could matter, but I feel like an informative note (something like the note removed in this commit) about removing the sign of
0⁻
in convert a string to a number is required, especially in regards to calculations because a consequence is thatcalc(1 / -0)
iscalc(infinity)
instead ofcalc(-infinity)
, which matches the output in JS, which performs division according to the rules of IEEE 754-2019, whereas in Type Checking (CSS Values):Can you also please tell me if there is any other difference between convert a string to a number and JS
Number()
, please?The text was updated successfully, but these errors were encountered: