Re: [csswg-drafts] [css-syntax-3][css-values-4] Add informative note about tokenization of negative 0 (#7472)

Writing `-0` in your CSS does not produce a negative zero; as you point out, the "convert a string to a number" algorithm produces the mathematical number zero, rather than the IEEE-754 signed zero. This is why all the examples in V&U that talk about negative zero produce it via a calculation, like `(-5 * 0)`, or handwave about the value space with 0<sup>+</sup>/0<sup>-</sup> which clearly aren't actually valid CSS.

> (something like the note removed in this [commit](https://github.com/w3c/csswg-drafts/commit/3eeafc30400155ab02e7934c522689ec06f9af1b#diff-fc1c32de78d227c8f0c8008469824444d1ba7f027e48a336125017d40b8f6f6fL3463))

Note that I didn't remove anything in that commit, I just switched from a misleading way to writing negative zero (`-0`, which looks like it's valid CSS) to a less-misleading way (0<sup>-</sup>).

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.

> Can you also please tell me if there is any other difference between convert a string to a number and JS Number(), please?

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 - `"-0"` produces a negative zero in JS, but not in CSS.

(If implementations are indeed producing a negative zero from `-0` in CSS, I'd be fine with changing Syntax to match, tho.)

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7472#issuecomment-1178209185 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 7 July 2022 20:47:41 UTC