<?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>24711</bug_id>
          
          <creation_ts>2009-03-19 19:48:20 -0700</creation_ts>
          <short_desc>1.95.toFixed(1) should equal &quot;1.9&quot; but does not</short_desc>
          <delta_ts>2010-08-27 12:56:54 -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>DUPLICATE</resolution>
          <dup_id>44745</dup_id>
          
          <bug_file_loc>javascript: alert(1.95.toFixed(1) === &quot;2.0&quot; ? &quot;FAIL&quot; : &quot;PASS&quot;)</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>HasReduction, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jeff Walden (remove +bwo to email)">jwalden+bwo</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>apeller</cc>
    
    <cc>barraclough</cc>
    
    <cc>brendan</cc>
    
    <cc>bugzilla33</cc>
    
    <cc>emacemac7</cc>
    
    <cc>gavin.sharp</cc>
    
    <cc>mrbkap</cc>
    
    <cc>zwarich</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>114435</commentid>
    <comment_count>0</comment_count>
    <who name="Jeff Walden (remove +bwo to email)">jwalden+bwo</who>
    <bug_when>2009-03-19 19:48:20 -0700</bug_when>
    <thetext>https://bugzilla.mozilla.org/show_bug.cgi?id=484293

This is reproducible in Safari 4 beta on 10.4 (r41760) and on Windows XP (just 4b).  May you have as much pleasure dealing with this as I did in (incorrectly) checking SpiderMonkey&apos;s behavior, because it would be the height of unfairness for me to hog all the fun.  :-)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114448</commentid>
    <comment_count>1</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2009-03-19 23:33:49 -0700</bug_when>
    <thetext>&lt;rdar://problem/6702946&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114453</commentid>
    <comment_count>2</comment_count>
    <who name="Cameron Zwarich (cpst)">zwarich</who>
    <bug_when>2009-03-20 01:10:09 -0700</bug_when>
    <thetext>I don&apos;t understand why 1.9 is the correct value. The ECMA spec gives an algorithm for toFixed in 15.7.4.5. This algorithm is copied almost literally by the implementation in JavaScriptCore. I&apos;ll double check this case by hand.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114454</commentid>
    <comment_count>3</comment_count>
    <who name="Jeff Walden (remove +bwo to email)">jwalden+bwo</who>
    <bug_when>2009-03-20 01:18:11 -0700</bug_when>
    <thetext>Cameron, see the Mozilla bug, it&apos;s all calculated by hand there -- just the problem of a flipped equality.  But if you do feel like running it out by hand, by all means feel free, because you&apos;ll get an even better idea of how much fun can be had here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114459</commentid>
    <comment_count>4</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2009-03-20 01:22:34 -0700</bug_when>
    <thetext>See also: bug 16651, bug 16653.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>114471</commentid>
    <comment_count>5</comment_count>
    <who name="Cameron Zwarich (cpst)">zwarich</who>
    <bug_when>2009-03-20 02:23:51 -0700</bug_when>
    <thetext>Okay, I see our mistake. This will be a bit of work to fix. There may be similar problems in other places.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>165698</commentid>
    <comment_count>6</comment_count>
    <who name="bugzilla33">bugzilla33</who>
    <bug_when>2009-11-22 01:06:45 -0800</bug_when>
    <thetext>toFixed rounds, not floors !
bug 24711 is not a Bug !!

(1.95) . toFixed( 1 ) = 2.0

because:

Math.round ( 1.95 * 10 ) / 10
equal 2</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>165700</commentid>
    <comment_count>7</comment_count>
    <who name="bugzilla33">bugzilla33</who>
    <bug_when>2009-11-22 01:16:04 -0800</bug_when>
    <thetext>Not a Bug.
All browsers before returns string value (IE, Opera, Konqueror, Chrome, Firefox) rounding a Number to defined scale.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>270672</commentid>
    <comment_count>8</comment_count>
    <who name="Gavin Barraclough">barraclough</who>
    <bug_when>2010-08-27 12:48:23 -0700</bug_when>
    <thetext>For a simpler explanation of why this is a valid bug, try:
    javascript:alert((1.95).toPrecision(21))

(but! this also doesn&apos;t work in ToT!) - the correct result should be 1.94999999999999995559.

Since the precise mathematical value passed to toFixed is closer to 1.9 than 2.0, 1.9 is the correct result.

This should be fixed by https://bugs.webkit.org/show_bug.cgi?id=44745

*** This bug has been marked as a duplicate of bug 44745 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>270679</commentid>
    <comment_count>9</comment_count>
    <who name="Gavin Barraclough">barraclough</who>
    <bug_when>2010-08-27 12:56:54 -0700</bug_when>
    <thetext>*** Bug 31777 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>