hixie: Redefine how to parse floats so that they are always narrowed to 32bit floats. (whatwg r4348)

hixie: Redefine how to parse floats so that they are always narrowed to
32bit floats. (whatwg r4348)

http://dev.w3.org/cvsweb/html5/spec/Overview.html?r1=1.3480&r2=1.3481&f=h
http://html5.org/tools/web-apps-tracker?from=4347&to=4348

===================================================================
RCS file: /sources/public/html5/spec/Overview.html,v
retrieving revision 1.3480
retrieving revision 1.3481
diff -u -d -r1.3480 -r1.3481
--- Overview.html 27 Oct 2009 10:02:22 -0000 1.3480
+++ Overview.html 27 Oct 2009 10:29:55 -0000 1.3481
@@ -2481,13 +2481,14 @@
 
    <!-- Ok. At this point we know we have a number. It might have
    trailing garbage which we'll ignore, but it's a number, and we
-   won't return an error. -->
+   won't return an error unless it's out of range. -->
 
    <li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
    U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the
    resulting sequence as a base-ten integer. Multiply <var title="">value</var> by that integer.</li>
 
-   <li>If <var title="">position</var> is past the end of <var title="">input</var>, return <var title="">value</var>.</li>
+   <li>If <var title="">position</var> is past the end of <var title="">input</var>, jump to the step labeled
+   <i>conversion</i>.</li>
 
    <li><p>If the character indicated by <var title="">position</var>
    is a U+002E FULL STOP (.), run these substeps:</p>
@@ -2495,8 +2496,9 @@
     <ol><li><p>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>, or if the character indicated by <var title="">position</var> is not one of U+0030 DIGIT ZERO (0)
-     to U+0039 DIGIT NINE (9), then return <var title="">value</var>.</li>
+     <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, or if the character indicated by <var title="">position</var> is not one of U+0030 DIGIT ZERO (0) to
+     U+0039 DIGIT NINE (9), then jump to the step labeled
+     <i>conversion</i>.</li>
 
      <li><p><i>Fraction loop</i>: Multiply <var title="">divisor</var>
      by ten.</li>
@@ -2507,11 +2509,12 @@
      <li><p>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>
+     <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled
+     <i>conversion</i>.</li>
 
      <li><p>If the character indicated by <var title="">position</var>
-     is one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), return
-     to the step labeled <i>fraction loop</i> in these
+     is one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), jump
+     back to the step labeled <i>fraction loop</i> in these
      substeps.</li>
 
     </ol></li>
@@ -2523,7 +2526,8 @@
     <ol><li><p>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>
+     <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled
+     <i>conversion</i>.</li>
 
      <li>
 
@@ -2535,20 +2539,22 @@
        <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>
+       <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled
+       <i>conversion</i>.</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>
+       <li><p>If <var title="">position</var> is past the end of <var title="">input</var>, then jump to the step labeled
+       <i>conversion</i>.</li>
 
       </ol></li>
 
      <li><p>If the character indicated by <var title="">position</var>
      is not one of U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9),
-     then return <var title="">value</var>.</li>
+     then jump to the step labeled <i>conversion</i>.</li>
 
      <li><p><a href="#collect-a-sequence-of-characters">Collect a sequence of characters</a> in the range
      U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the
@@ -2559,7 +2565,19 @@
 
     </ol></li>
 
-   <li><p>Return <var title="">value</var>.</li>
+   <li><p><i>Conversion</i>: Let <var title="">S</var> be the set of
+   finite IEEE 754 single-precision floating point values except
+   &minus;0, but with two special values added: 2<sup title="">128</sup> and &minus;2<sup title="">128</sup>.</li>
+
+   <li><p>Let <var title="">rounded-value</var> be the number in <var title="">S</var> that is closest to <var title="">value</var>,
+   selecting the number with an even significand if there are two
+   equally close values. (The two special values 2<sup title="">128</sup> and &minus;2<sup title="">128</sup> are
+   considered to have even significands for this purpose.)</li>
+
+   <li><p>If <var title="">rounded-value</var> is 2<sup title="">128</sup> or &minus;2<sup title="">128</sup>, return an
+   error.</li>
+
+   <li><p>Return <var title="">rounded-value</var>.</li>
 
   </ol></div><h5 id="ratios"><span class="secno">2.4.4.4 </span>Ratios</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i><p class="note">The algorithms described in this section are used by
   the <code><a href="#the-progress-element">progress</a></code> and <code><a href="#the-meter-element">meter</a></code> elements.<p>A <dfn id="valid-denominator-punctuation-character">valid denominator punctuation character</dfn> is one of
@@ -4871,10 +4889,8 @@
   <p>If a reflecting IDL attribute is a floating point number type
   (<code>float</code>), then, on getting, the content attribute must
   be parsed according to the <a href="#rules-for-parsing-floating-point-number-values">rules for parsing floating point
-  number values</a>, and if that is successful, and the value is in
-  the range of the IDL attribute's type (excluding infinities), the
-  resulting value must be returned, truncating it if necessary. If, on
-  the other hand, it fails or returns an out of range value, or if the
+  number values</a>, and if that is successful, the resulting value
+  must be returned. If, on the other hand, it fails, 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 <a href="#best-representation-of-the-number-as-a-floating-point-number">best representation of the number as a

Received on Tuesday, 27 October 2009 10:30:42 UTC