W3C home > Mailing lists > Public > www-style@w3.org > February 2010

Re: Scientific notation in numbers

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 10 Feb 2010 17:50:30 -0500
Message-ID: <4B733836.6050403@mit.edu>
To: Zack Weinberg <zweinberg@mozilla.com>
CC: "www-style@w3.org" <www-style@w3.org>
On 2/10/10 4:27 PM, Zack Weinberg wrote:
> That means what I said to Chris Lilley about the style-attribute spec
> is wrong.  And now I'm wondering where the SVG spec *expects* scientific
> notation to work.

http://www.w3.org/TR/SVG/types.html#BasicDataTypes says for <number>:

  <number> (real number value): The specification of real number
  values is different for property values than for XML attribute values.
   * CSS2 [CSS2] states that a property  value which is a <number>
     is specified in decimal notation (i.e., a <decimal-number>), which
     consists of either an <integer>, or an optional sign character
     followed by zero or more digits followed by a dot (.) followed by
     one or more digits. Thus, for conformance with CSS2, any property
     in SVG which accepts <number> values is specified in decimal
     notation only.
   * For SVG's XML attributes, to provide as much scalability in numeric
     values as possible, real number values can be provided either in
     decimal notation or in scientific notation (i.e., a
     <scientific-number>), which consists of a <decimal-number>
     immediately followed by the letter "e" or "E" immediately followed
     by an <integer>.

Thus an implementation of SVG 1.1 would be expected to parse scientific 
notation only in the XML attribute values.  Then <length> is defined in 
terms of <number> and explicitly points to the above distinction.

This does mean that you can do:

   <rect id="foo" width="1e3"/>

but can't do:

   <style>#foo { width: 1e3; }</style>
   <rect id="foo"/>

and need to use "width: 1000;" instead.

I don't know what changes have been made in the SVG 2 drafts.

-Boris
Received on Wednesday, 10 February 2010 22:51:08 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:24 GMT