W3C home > Mailing lists > Public > public-css-archive@w3.org > December 2019

[csswg-drafts] [css-values-4] Specify that calculation trees explicitly work in double precision (#4551)

From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
Date: Mon, 02 Dec 2019 03:25:55 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-530865148-1575257154-sysbot+gh@w3.org>
tabatkins has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values-4] Specify that calculation trees explicitly work in double precision ==
In [this twitter thread by @starsandrobots](https://twitter.com/starsandrobots/status/1199757377286754309), a CSS hack is shared that, in Chrome, causes values to snap to multiples of 1024px. This is because Chrome evaluates calc()s in  f64 precision, and the hack uses very large values that overflow the safe-integer range of a double by several bits.

In general CSS precision is intentionally unspecified (tho not *explicitly* unspecified; I should fix that...), to allow impls freedom to use their desired size of LayoutUnit, pack values into optimized structs, etc., so numeric precision/width can vary across impls and across properties in a single impl. But it seems likely that, within a calc(), impls will use a single consistent precision (since otherwise it would require multiple separate implementations of calculation trees and all the math functions for each numeric type).

Currently this precision also varies across impls (the hack doesn't work in Firefox, since they use f32s in calculation trees), but it seems likely that we can standardize this value across impls, and as people get used to using more complex calc()s, it's likely they'll come to depend on particular precisions, accidentally or purposefully. Since the Typed OM exposes numbers in f64s (JS's native numeric type), I think we should specify that calculation trees do their work in that precision too.

Thoughts? @emilio @heycam @domenic @smfr @bfgeek @xiaochengh 

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4551 using your GitHub account
Received on Monday, 2 December 2019 03:25:56 UTC

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