[html5] r4348 - [giow] (0) Redefine how to parse floats so that they are always narrowed to 32bi [...]
whatwg at whatwg.org
whatwg at whatwg.org
Tue Oct 27 03:29:51 PDT 2009
Author: ianh
Date: 2009-10-27 03:29:47 -0700 (Tue, 27 Oct 2009)
New Revision: 4348
Modified:
complete.html
index
source
Log:
[giow] (0) Redefine how to parse floats so that they are always narrowed to 32bit floats.
Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=8047
Modified: complete.html
===================================================================
--- complete.html 2009-10-27 10:02:14 UTC (rev 4347)
+++ complete.html 2009-10-27 10:29:47 UTC (rev 4348)
@@ -2945,13 +2945,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>
@@ -2959,8 +2960,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>
@@ -2971,11 +2973,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>
@@ -2987,7 +2990,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>
@@ -2999,20 +3003,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
@@ -3023,8 +3029,20 @@
</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
+ −0, but with two special values added: 2<sup title="">128</sup> and −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 −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 −2<sup title="">128</sup>, return an
+ error.</li>
+
+ <li><p>Return <var title="">rounded-value</var>.</li>
+
</ol></div>
@@ -5549,10 +5567,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
Modified: index
===================================================================
--- index 2009-10-27 10:02:14 UTC (rev 4347)
+++ index 2009-10-27 10:29:47 UTC (rev 4348)
@@ -2763,13 +2763,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>
@@ -2777,8 +2778,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>
@@ -2789,11 +2791,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>
@@ -2805,7 +2808,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>
@@ -2817,20 +2821,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
@@ -2841,8 +2847,20 @@
</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
+ −0, but with two special values added: 2<sup title="">128</sup> and −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 −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 −2<sup title="">128</sup>, return an
+ error.</li>
+
+ <li><p>Return <var title="">rounded-value</var>.</li>
+
</ol></div>
@@ -5367,10 +5385,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
Modified: source
===================================================================
--- source 2009-10-27 10:02:14 UTC (rev 4347)
+++ source 2009-10-27 10:29:47 UTC (rev 4348)
@@ -1877,7 +1877,7 @@
<!-- 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><span>Collect a sequence of characters</span> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the
@@ -1885,7 +1885,8 @@
title="">value</var> by that integer.</p></li>
<li>If <var title="">position</var> is past the end of <var
- title="">input</var>, return <var title="">value</var>.</li>
+ 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>
@@ -1897,8 +1898,9 @@
<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>
+ 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.</p></li>
@@ -1912,11 +1914,12 @@
character.</p></li>
<li><p>If <var title="">position</var> is past the end of <var
- title="">input</var>, then return <var title="">value</var>.</li>
+ 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.</p></li>
</ol>
@@ -1933,7 +1936,8 @@
character.</p></li>
<li><p>If <var title="">position</var> is past the end of <var
- title="">input</var>, then return <var title="">value</var>.</li>
+ title="">input</var>, then jump to the step labeled
+ <i>conversion</i>.</li>
<li>
@@ -1948,8 +1952,8 @@
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>
+ title="">input</var>, then jump to the step labeled
+ <i>conversion</i>.</li>
</ol>
@@ -1962,8 +1966,8 @@
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>
+ title="">input</var>, then jump to the step labeled
+ <i>conversion</i>.</li>
</ol>
@@ -1971,7 +1975,7 @@
<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><span>Collect a sequence of characters</span> in the range
U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), and interpret the
@@ -1985,8 +1989,24 @@
</li>
- <li><p>Return <var title="">value</var>.</p></li>
+ <li><p><i>Conversion</i>: Let <var title="">S</var> be the set of
+ finite IEEE 754 single-precision floating point values except
+ −0, but with two special values added: 2<sup
+ title="">128</sup> and −2<sup title="">128</sup>.</p></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 −2<sup title="">128</sup> are
+ considered to have even significands for this purpose.)</p></li>
+
+ <li><p>If <var title="">rounded-value</var> is 2<sup
+ title="">128</sup> or −2<sup title="">128</sup>, return an
+ error.</p></li>
+
+ <li><p>Return <var title="">rounded-value</var>.</p></li>
+
</ol>
</div>
@@ -5074,10 +5094,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 <span>rules for parsing floating point
- number values</span>, 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</span>, 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 <span>best representation of the number as a
More information about the Commit-Watchers
mailing list