<?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>14468</bug_id>
          
          <creation_ts>2007-06-29 15:55:47 -0700</creation_ts>
          <short_desc>JS Number.toPrecision(20) and Number.toPrecision(21) are incorrect</short_desc>
          <delta_ts>2010-08-27 12:52:06 -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>523.x (Safari 3)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>44745</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>PlatformOnly</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Pam Greene (IRC:pamg)">pam</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>barraclough</cc>
    
    <cc>webkit</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>5880</commentid>
    <comment_count>0</comment_count>
    <who name="Pam Greene (IRC:pamg)">pam</who>
    <bug_when>2007-06-29 15:55:47 -0700</bug_when>
    <thetext>Number(0.0001234567890123456789012345).toPrecision(20) returns
       0.00012345678901234565000

Number(0.0001234567890123456789012345).toPrecision(21) also returns
       0.000123456789012345650000

Tests failing:
fast/js/kde/Number.html

The problem is that, due to the compiler or FPU or what have you, 1.000000...e+22 * 10.0 is returning 9.999...92e+22 rather than 1.000000...e+23, so intPow10() in kjs/number_object.cpp is wrong and so is toPrecision().

For reference, IE7 gets the result right, and Firefox 2 gives a different wrong answer (0.00012345678901234567130).

A couple of other numerical algorithms I tried give the same erroneous result.  Special-casing 1e+22 is just ugly. I&apos;m tempted to add a precision argument to UString::from(double) and use its string manipulations instead. :/  Any other suggestions?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>70742</commentid>
    <comment_count>1</comment_count>
    <who name="Robert Blaut">webkit</who>
    <bug_when>2008-02-15 03:16:19 -0800</bug_when>
    <thetext>Confirmed on the latest Webkit on Windows.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>270675</commentid>
    <comment_count>2</comment_count>
    <who name="Gavin Barraclough">barraclough</who>
    <bug_when>2010-08-27 12:52:06 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 44745 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>