Skip to content

Commit

Permalink
[] (0) Floats: Allow '1e+0' syntax. Require it for serialising floati…
Browse files Browse the repository at this point in the history
…ng point numbers. Other editorial fixes.

git-svn-id: http://svn.whatwg.org/webapps@2731 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Feb 1, 2009
1 parent 86f7897 commit 2e06b93
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 29 deletions.
49 changes: 35 additions & 14 deletions index
Expand Up @@ -2276,7 +2276,8 @@
<ol><li>Either a U+0065 LATIN SMALL LETTER E character or a U+0045
LATIN CAPITAL LETTER E character.</li>

<li>Optionally, a U+002D HYPHEN-MINUS ("-") character.</li>
<li>Optionally, a U+002D HYPHEN-MINUS ("-") character or U+002B
PLUS SIGN ("+") character.</li>

<li>A series of characters in the range U+0030 DIGIT ZERO (0) to
U+0039 DIGIT NINE (9).</li>
Expand All @@ -2292,8 +2293,17 @@
HYPHEN-MINUS ("-") character and the number is not zero), and where
the exponent is the number after the E, if any (interpreted as a
negative number if there is a U+002D HYPHEN-MINUS ("-") character
between the E and the number and the number is not zero). If there
is no E, then the exponent is treated as zero.</p>
between the E and the number and the number is not zero, or else
ignoring a U+002B PLUS SIGN ("+") character between the E and the
number if there is one). If there is no E, then the exponent is
treated as zero.</p>

<p class=note>The values &plusmn;Infinity and NaN are not <a href=#valid-floating-point-number title="valid floating point number">valid floating point
numbers</a>.</p>

<p>The <dfn id=best-representation-of-the-floating-point-number>best representation of the floating point number</dfn>
<var title="">n</var> is the string obtained from applying the
ECMAScript operator ToString to <var title="">n</var>.</p>

<p>The <dfn id=rules-for-parsing-floating-point-number-values>rules for parsing floating point number values</dfn> are
as given in the following algorithm. As with the previous
Expand Down Expand Up @@ -2396,6 +2406,14 @@

<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then return <var title="">value</var>.</li>

</ol><p>Otherwise, if the character indicated by <var title="">position</var> is a U+002B PLUS SIGN ("+")
character:</p>

<ol><li>Advance <var title="">position</var> to the next
character.</li>

<li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then return <var title="">value</var>.</li>

</ol></li>

<li><p>If the character indicated by <var title="">position</var>
Expand Down Expand Up @@ -4036,7 +4054,7 @@
the element</i>, as defined by the XML Base specification, with
<i>the base URI of the document entity</i> being defined as the
<a href=#document-base-url>document base URL</a> of the <code>Document</code> that
owns the element.</p>
owns the element. <a href=#refsXMLBASE>[XMLBASE]</a></p>

<p>For the purposes of the XML Base specification, user agents
must act as if all <code>Document</code> objects represented XML
Expand Down Expand Up @@ -5263,10 +5281,12 @@
returned. If, on the other hand, it fails or returns an out of range
value, or if the attribute is absent, the default value must be
returned instead, or 0.0 if there is no default value. On setting,
the given value must be converted to the shortest possible string
representing the number as a <a href=#valid-floating-point-number>valid floating point
number</a> in base ten and then that string must be used as the
new content attribute value.</p>
the given value must be converted to the <a href=#best-representation-of-the-floating-point-number>best representation
of the floating point number</a> and then that string must be
used as the new content attribute value.</p>

<p class=note>The values &plusmn;Infinity and NaN throw an
exception on setting, as defined by WebIDL. <a href=#refsWEBIDL>[WEBIDL]</a></p>

<p>If a reflecting DOM attribute is of the type
<code><a href=#domtokenlist-0>DOMTokenList</a></code>, then on getting it must return a
Expand Down Expand Up @@ -26458,9 +26478,9 @@ interface <dfn id=htmlformelement>HTMLFormElement</dfn> : <a href=#htmlelement>H
number values</a> to it. User agents must not allow the user to
set the <a href=#concept-fe-value title=concept-fe-value>value</a> to a string that
is not a <a href=#valid-floating-point-number>valid floating point number</a>. If the user agent
provides a user interface for selecting a number, then the <a href=#concept-fe-value title=concept-fe-value>value</a> must be set to a <a href=#valid-floating-point-number>valid
floating point number</a> representing the user's selection. User
agents should allow the user to set the <a href=#concept-fe-value title=concept-fe-value>value</a> to the empty string.</p>
provides a user interface for selecting a number, then the <a href=#concept-fe-value title=concept-fe-value>value</a> must be set to the <a href=#best-representation-of-the-floating-point-number>best
representation of the floating point number</a> representing the
user's selection. User agents should allow the user to set the <a href=#concept-fe-value title=concept-fe-value>value</a> to the empty string.</p>

<p>The <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute, if
specified, must have a value that is a <a href=#valid-floating-point-number>valid floating point
Expand Down Expand Up @@ -26572,9 +26592,10 @@ interface <dfn id=htmlformelement>HTMLFormElement</dfn> : <a href=#htmlelement>H
number values</a> to it. User agents must not allow the user to
set the <a href=#concept-fe-value title=concept-fe-value>value</a> to a string that
is not a <a href=#valid-floating-point-number>valid floating point number</a>. If the user agent
provides a user interface for selecting a number, then the <a href=#concept-fe-value title=concept-fe-value>value</a> must be set to a <a href=#valid-floating-point-number>valid
floating point number</a> representing the user's selection. User
agents must not allow the user to set the <a href=#concept-fe-value title=concept-fe-value>value</a> to the empty string.</p>
provides a user interface for selecting a number, then the <a href=#concept-fe-value title=concept-fe-value>value</a> must be set to a <a href=#best-representation-of-the-floating-point-number>best
representation of the floating point number</a> representing the
user's selection. User agents must not allow the user to set the
<a href=#concept-fe-value title=concept-fe-value>value</a> to the empty string.</p>

<p>The <code title=attr-input-value><a href=#attr-input-value>value</a></code> attribute, if
specified, must have a value that is a <a href=#valid-floating-point-number>valid floating point
Expand Down
59 changes: 44 additions & 15 deletions source
Expand Up @@ -1352,7 +1352,8 @@
<li>Either a U+0065 LATIN SMALL LETTER E character or a U+0045
LATIN CAPITAL LETTER E character.</li>

<li>Optionally, a U+002D HYPHEN-MINUS ("-") character.</li>
<li>Optionally, a U+002D HYPHEN-MINUS ("-") character or U+002B
PLUS SIGN ("+") character.</li>

<li>A series of characters in the range U+0030 DIGIT ZERO (0) to
U+0039 DIGIT NINE (9).</li>
Expand All @@ -1372,8 +1373,18 @@
HYPHEN-MINUS ("-") character and the number is not zero), and where
the exponent is the number after the E, if any (interpreted as a
negative number if there is a U+002D HYPHEN-MINUS ("-") character
between the E and the number and the number is not zero). If there
is no E, then the exponent is treated as zero.</p>
between the E and the number and the number is not zero, or else
ignoring a U+002B PLUS SIGN ("+") character between the E and the
number if there is one). If there is no E, then the exponent is
treated as zero.</p>

<p class="note">The values &plusmn;Infinity and NaN are not <span
title="valid floating point number">valid floating point
numbers</span>.</p>

<p>The <dfn>best representation of the floating point number</dfn>
<var title="">n</var> is the string obtained from applying the
ECMAScript operator ToString to <var title="">n</var>.</p>

<p>The <dfn>rules for parsing floating point number values</dfn> are
as given in the following algorithm. As with the previous
Expand Down Expand Up @@ -1504,6 +1515,21 @@

</ol>

<p>Otherwise, if the character indicated by <var
title="">position</var> is a U+002B PLUS SIGN ("+")
character:</p>

<ol>

<li>Advance <var title="">position</var> to the next
character.</li>

<li><p>If <var title="">position</var> is past the end of <var
title="">input</var>, then return <var
title="">value</var>.</li>

</ol>

</li>

<li><p>If the character indicated by <var title="">position</var>
Expand Down Expand Up @@ -3582,7 +3608,7 @@
the element</i>, as defined by the XML Base specification, with
<i>the base URI of the document entity</i> being defined as the
<span>document base URL</span> of the <code>Document</code> that
owns the element.</p>
owns the element. <a href="#refsXMLBASE">[XMLBASE]</a></p>

<p>For the purposes of the XML Base specification, user agents
must act as if all <code>Document</code> objects represented XML
Expand Down Expand Up @@ -5056,10 +5082,13 @@
returned. If, on the other hand, it fails or returns an out of range
value, or if the attribute is absent, the default value must be
returned instead, or 0.0 if there is no default value. On setting,
the given value must be converted to the shortest possible string
representing the number as a <span>valid floating point
number</span> in base ten and then that string must be used as the
new content attribute value.</p>
the given value must be converted to the <span>best representation
of the floating point number</span> and then that string must be
used as the new content attribute value.</p>

<p class="note">The values &plusmn;Infinity and NaN throw an
exception on setting, as defined by WebIDL. <a
href="#refsWEBIDL">[WEBIDL]</a></p>

<p>If a reflecting DOM attribute is of the type
<code>DOMTokenList</code>, then on getting it must return a
Expand Down Expand Up @@ -29441,9 +29470,9 @@ interface <dfn>HTMLFormElement</dfn> : <span>HTMLElement</span> {
set the <span title="concept-fe-value">value</span> to a string that
is not a <span>valid floating point number</span>. If the user agent
provides a user interface for selecting a number, then the <span
title="concept-fe-value">value</span> must be set to a <span>valid
floating point number</span> representing the user's selection. User
agents should allow the user to set the <span
title="concept-fe-value">value</span> must be set to the <span>best
representation of the floating point number</span> representing the
user's selection. User agents should allow the user to set the <span
title="concept-fe-value">value</span> to the empty string.</p>

<p>The <code title="attr-input-value">value</code> attribute, if
Expand Down Expand Up @@ -29565,10 +29594,10 @@ interface <dfn>HTMLFormElement</dfn> : <span>HTMLElement</span> {
set the <span title="concept-fe-value">value</span> to a string that
is not a <span>valid floating point number</span>. If the user agent
provides a user interface for selecting a number, then the <span
title="concept-fe-value">value</span> must be set to a <span>valid
floating point number</span> representing the user's selection. User
agents must not allow the user to set the <span
title="concept-fe-value">value</span> to the empty string.</p>
title="concept-fe-value">value</span> must be set to a <span>best
representation of the floating point number</span> representing the
user's selection. User agents must not allow the user to set the
<span title="concept-fe-value">value</span> to the empty string.</p>

<p>The <code title="attr-input-value">value</code> attribute, if
specified, must have a value that is a <span>valid floating point
Expand Down

0 comments on commit 2e06b93

Please sign in to comment.