W3C home > Mailing lists > Public > www-style@w3.org > September 2008

Re: Exponents in <number>

From: Dean Jackson <dino@apple.com>
Date: Tue, 9 Sep 2008 07:31:29 +1000
Cc: www-style@w3.org
Message-Id: <75796CA6-03C2-4B81-BE43-40BCE2682FA8@apple.com>
To: Bert Bos <bert@w3.org>

Hi Bert,

On 06/09/2008, at 8:38 PM, Bert Bos wrote:

> Changing it would be difficult. Existing software is free to rewrite  
> "100E+5" as "100e + 5" and "1.4E+1cm" as "1.4e + 1cm". And if some  
> hypothetical new software rewrites 100 as 1E+2, then old programs  
> will not understand the supposedly equivalent value anymore.

Yeah, I suspected this would be a difficult change since it is at the  
syntax level.

>> 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.
>
> CSS actually doesn't need a lot of range or accuracy. Typical sizes  
> in CSS range from half a pt to a couple of cm. That's a ratio of  
> 1:10000 or  about 15 bits. And as for accuracy, the wavelength of  
> light is about 0.001 pt, so smaller sizes than that are invisible  
> anyway. Those limits aren't based on limits in technology, but on  
> limits in people, and they aren't likely to change for the next  
> 100,000 years.

This is true, except that I can imagine using CSS to display content  
on a massive screen like those at a football stadium. But that doesn't  
really significantly change the orders of magnitude you're talking  
about.

What *does* change it is transforms. If you nest elements and  
transform them, especially with animation (either via JS or the  
proposed CSS), then you need the precision. And it isn't restricted to  
unusual use cases - a regular rotation needs such accuracy.

Another example is opacity, where there is significantly different  
behaviour for numbers < 1 as opposed to 1 (and opacity is unitless).

In summary, I think it's time to start considering higher precision.

Meanwhile, here is a test case that shows Mozilla and WebKit both  
return numbers in exponential format (I didn't test other browsers):

<html>
<head>
   <title>Testing getComputedStyle return values</title>
   <style type="text/css" media="screen">
     #a {
       opacity: 0.0000000001;
     }
   </style>
</head>
<body>
   <p id="a">Very transparent paragraph</p>
   <p>
     <script type="text/javascript" charset="utf-8">
       document.write("Opacity is: " +  
window.getComputedStyle(document.getElementById("a"), "").opacity);
     </script>
   </p>
</body>
</html>
Received on Monday, 8 September 2008 21:32:16 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:12 GMT