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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>24156</bug_id>
          
          <creation_ts>2009-02-25 01:47:21 -0800</creation_ts>
          <short_desc>Unary + conversion to number fails for negative hexadecimal (-0xff) 0x</short_desc>
          <delta_ts>2011-09-07 00:54:05 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc>http://groups.google.com/group/comp.lang.javascript/msg/8f8fcfdc42ee3960</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jorge">jorgechamorro</reporter>
          <assigned_to name="Cameron Zwarich (cpst)">zwarich</assigned_to>
          <cc>barraclough</cc>
    
    <cc>jorgechamorro</cc>
    
    <cc>zwarich</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>110924</commentid>
    <comment_count>0</comment_count>
    <who name="Jorge">jorgechamorro</who>
    <bug_when>2009-02-25 01:47:21 -0800</bug_when>
    <thetext>See: 
javascript:s= &quot;0x12&quot;;alert((+s)+ &quot;,&quot;+ parseInt(s,16)); //-&gt; 18,18 
but: 
javascript:s= &quot;-0x12&quot;;alert((+s)+ &quot;,&quot;+ parseInt(s,16)); //-&gt; NaN,-18</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111116</commentid>
    <comment_count>1</comment_count>
    <who name="Cameron Zwarich (cpst)">zwarich</who>
    <bug_when>2009-02-25 23:22:11 -0800</bug_when>
    <thetext>This works as expected. See section 9.3.1 of the ECMA spec:

http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf

The ToNumber operation (which is used by the unary plus operator) only handles negative signs for decimal numbers, not hex or octal. It might be a bit strange, but it&apos;s the spec.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111142</commentid>
    <comment_count>2</comment_count>
    <who name="Jorge">jorgechamorro</who>
    <bug_when>2009-02-26 01:03:21 -0800</bug_when>
    <thetext>(In reply to comment #1)
&gt;
&gt; The ToNumber operation (which is used by the unary plus operator) only handles
&gt; negative signs for decimal numbers, not hex or octal. It might be a bit
&gt; strange, but it&apos;s the spec.

FF, Opera and Chrome handle them fine, and that might be perceived as &quot;better&quot;. Better than the spec -if you want- but better, after all. Now, what&apos;s the best browser ? Not Safari when it comes to hex string conversion to number... IMO, in this case better is better than the spec. Safari is doing it to/in-spec, but worse.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>111183</commentid>
    <comment_count>3</comment_count>
    <who name="Cameron Zwarich (cpst)">zwarich</who>
    <bug_when>2009-02-26 07:50:25 -0800</bug_when>
    <thetext>If it&apos;s a potential compatibility issue down the road, then it probably makes sense to match Firefox on this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>463214</commentid>
    <comment_count>4</comment_count>
    <who name="Gavin Barraclough">barraclough</who>
    <bug_when>2011-09-07 00:54:05 -0700</bug_when>
    <thetext>This was a bug in other browsers, and fixed in the latest FireFox.  Behaves correctly.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>