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

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 using your GitHub account

Received on Sunday, 18 February 2018 02:11:01 UTC