Re: Scientific notation in numbers

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 UTC