<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>12220</bug_id>
          
          <creation_ts>2011-03-02 17:04:07 +0000</creation_ts>
          <short_desc>Make sure rules for parsing a float are the same in HTML and in Javascript specifications</short_desc>
          <delta_ts>2011-08-22 20:57:35 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>LC1 HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          <see_also>http://www.w3.org/Bugs/Public/show_bug.cgi?id=12296</see_also>
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#rules-for-parsing-floating-point-number-values</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>13689</dependson>
          <blocked>11887</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Mounir Lamouri">mounir</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>ayg</cc>
    
    <cc>bugs</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>contributor</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>46177</commentid>
    <comment_count>0</comment_count>
    <who name="Mounir Lamouri">mounir</who>
    <bug_when>2011-03-02 17:04:07 +0000</bug_when>
    <thetext>After a discussion with Boris on IRC, it seems like the current way of parsing floating point numbers in HTML (see URL) do not match what javascript does. This really should match.

One of the issue Boris mentioned is that HTML specs do not allow a leading &apos;+&apos;. According to him, other issues might exist.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46180</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-03-02 17:25:59 +0000</bug_when>
    <thetext>For example, &quot;1.e5&quot; is parsed as 1.0000 by the current HTML5 algorithm, but 100000.0000 by JS and general string-to-float libraries.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46181</commentid>
    <comment_count>2</comment_count>
    <who name="Mounir Lamouri">mounir</who>
    <bug_when>2011-03-02 17:28:42 +0000</bug_when>
    <thetext>And at step 12, sub-step 2, we have to go to /conversion/ if the character at /position/ isn&apos;t in [0-9]. It seems like a mistake given that we are skipping step 13.
That would make these two strings being parsed differently: &quot;1.e5&quot; and &quot;1.0e5&quot;. The former would be converted to the number &quot;1&quot; and the later would be parsed to the number &quot;100000&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46182</commentid>
    <comment_count>3</comment_count>
    <who name="Mounir Lamouri">mounir</who>
    <bug_when>2011-03-02 17:29:46 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; And at step 12, sub-step 2, we have to go to /conversion/ if the character at
&gt; /position/ isn&apos;t in [0-9]. It seems like a mistake given that we are skipping
&gt; step 13.
&gt; That would make these two strings being parsed differently: &quot;1.e5&quot; and &quot;1.0e5&quot;.
&gt; The former would be converted to the number &quot;1&quot; and the later would be parsed
&gt; to the number &quot;100000&quot;.

This was conflicting with Boris&apos; comment but I still posted it given that it has more details about where the issue is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46206</commentid>
    <comment_count>4</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-03-03 00:21:05 +0000</bug_when>
    <thetext>Why doesn&apos;t HTML just defer to ES here?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46681</commentid>
    <comment_count>5</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-03-14 14:15:17 +0000</bug_when>
    <thetext>*** Bug 12296 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>46683</commentid>
    <comment_count>6</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-03-14 14:17:03 +0000</bug_when>
    <thetext>Bug 12296 is actually not a duplicate, but it&apos;s related: parsing integers also doesn&apos;t match ES.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48102</commentid>
    <comment_count>7</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-05-05 21:16:00 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given below
Rationale:

We can&apos;t use the exact parseFloat() algorithm since that supports things like &quot;Infinity&quot;.

I&apos;ve fixed the algorithm to support the syntax ES supports, though. These mistakes were unintentional.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48103</commentid>
    <comment_count>8</comment_count>
    <who name="">contributor</who>
    <bug_when>2011-05-05 21:16:50 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r6084.
Check-in comment: Fix a couple of parser bugs that made valid ES floating point numbers not get parsed to the same meaning in HTML attributes
http://html5.org/tools/web-apps-tracker?from=6083&amp;to=6084</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48192</commentid>
    <comment_count>9</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-05-06 17:14:24 +0000</bug_when>
    <thetext>If the only problem is things like Infinity, why don&apos;t you invoke ParseFloat from ES and then explicitly handle the Infinity/-Infinity/NaN cases?  That way you don&apos;t risk any unexpected differences.

The step &quot;Let rounded-value be the number in S that is closest to value, selecting the number with an even significand if there are two equally close values&quot; in the current algorithm is particularly unreasonable.  That&apos;s not algorithmic at all.  There&apos;s no obvious way to implement it, unless maybe you&apos;re a lot more familiar with floating-point numbers than I am.

In particular, my inability to implement the spec&apos;s algorithm makes it hard to rigorously test it.  I ran into this when doing the reflection tests.  If the spec was based on parseFloat(), I could at least test that the parseFloat() implementation matches the HTML floating-point parsing implementation, in addition to testing various specific values to make sure they&apos;re correct.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48231</commentid>
    <comment_count>10</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-05-06 20:17:43 +0000</bug_when>
    <thetext>Um, the text you&apos;re complaining about is almost verbatim from the ES spec!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48241</commentid>
    <comment_count>11</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-05-06 20:42:08 +0000</bug_when>
    <thetext>Okay, fine, that particular line is.  There&apos;s still no call to respecify the whole thing in different words, *especially* if you intend the results to be the same.  It just makes life harder for implementers, authors, and testers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>52120</commentid>
    <comment_count>12</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-08-03 06:50:21 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Rejected
Change Description: no spec change
Rationale: Much as with integers, I disagree that the ES spec&apos;s algorithm is what we actually want here. It&apos;s not stable on the long term, and if the algorithm isn&apos;t truly identical, I think the benefits of deferring to another spec with a delta are much oversold.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>52202</commentid>
    <comment_count>13</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-08-03 17:18:40 +0000</bug_when>
    <thetext>As with bug 12296, I disagree.  Browsers have to support the ES spec anyway, and it&apos;s a waste of everyone&apos;s time to have a second algorithm that&apos;s extremely similar but not quite the same.  But I doubt I&apos;ll convince you.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>52205</commentid>
    <comment_count>14</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-08-03 17:32:22 +0000</bug_when>
    <thetext>Oh, whoops, I&apos;m not the filer here, so I shouldn&apos;t mark it CLOSED or Disagree.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>52410</commentid>
    <comment_count>15</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2011-08-04 05:01:12 +0000</bug_when>
    <thetext>mass-moved component to LC1</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>