W3C home > Mailing lists > Public > public-css-archive@w3.org > February 2018

Re: [csswg-drafts] [cssom] How should extremely small <number>s be serialized?

From: Xidorn Quan via GitHub <sysbot+gh@w3.org>
Date: Sun, 18 Feb 2018 02:10:58 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-366486954-1518919857-sysbot+gh@w3.org>
Looks like the spec doesn't agree with any of the implementation here.

I think the idea here should be to keep 6 decimals starting from the first non-zero decimal, i.e. leading zeros are excluded from the count, so something like `0.00123456789` would be serialized to `0.00123457`. This matches the current behavior of Firefox and Chrome.

The reason to choose 6 decimals is probably because precision of a single precision floating-point number is only 7.22 decimals. I'm not sure whether it is safe to do 7 decimals, but it definitely shouldn't go beyond that.

Regarding the scientific notation, it seems Firefox starts using scientific notation when it is smaller than 1e-6, while Chrome starts doing so when smaller than 1e-4. Also Chrome starts using scientific notation when the number is not smaller than 1e6, while Firefox always serialize the whoe number if it is an integer.

I guess it makes sense to allow serialization to scientific notation on a boundary decided by implementations. This should be clarified in the spec.

-- 
GitHub Notification of comment by upsuper
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2330#issuecomment-366486954 using your GitHub account
Received on Sunday, 18 February 2018 02:11:01 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:24 UTC