Re: Exponents in <number>

On 06/09/2008, at 6:49 AM, Tab Atkins Jr. wrote:

> On Fri, Sep 5, 2008 at 3:43 PM, Dean Jackson <dino@apple.com> wrote:
>
> According to CSS 3 Values and Units, numbers can't be of the form  
> 1.0e20.
>
> http://www.w3.org/TR/css3-values/#numbers
>
> "A <number> can either be an <integer>, or it can be zero or more  
> digits followed by a dot (.) followed by one or more digits."
>
> Was there a reason for not allowing this?
>
> Would it be possible to change the syntax to allow the format? (I  
> assume this would be classified as a significant change)
>
> I'm curious - do you have *any* use-cases for a number that can't be  
> plainly stated without exponents?

As tempting as it is to sit around all day reading specifications and  
looking for inconsistencies, I actually did come across this in real  
content. In this case is was for implementing getComputedStyle.

Of course, this doesn't mean plainly stating the number is impossible.  
I just think that exponents are more user friendly than something like  
0.000000000000001234.

> I suspect "there's absolutely no need for it" was the reason for not  
> allowing it.


I suspect that this restriction in CSS was not intentional. However,  
if it was intentional then I think "absolutely no need for it" was the  
wrong reason. There was "absolutely no need" for more than 640K of RAM.

Large or small numbers can happen, especially when you nest things and  
the scale accumulates. Accuracy matters. With features like page zoom,  
transformations and resolution-independent displays it's going to  
become more common.

Two more notes: firstly, SVG allows numbers with exponents. Secondly,  
some browsers actually return numbers in exponential format.

Dean

Received on Friday, 5 September 2008 21:43:24 UTC