<?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>187650</bug_id>
          
          <creation_ts>2018-07-13 11:16:43 -0700</creation_ts>
          <short_desc>Number.toPrecision returns a wrong value</short_desc>
          <delta_ts>2021-05-06 17:46:26 -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>Safari 11</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></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>isol2</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ashvayka</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1441926</commentid>
    <comment_count>0</comment_count>
    <who name="">isol2</who>
    <bug_when>2018-07-13 11:16:43 -0700</bug_when>
    <thetext>Version: JavaScriptCore v233804
OS: Ubuntu 16.04 x64

Hi everyone,
I found an issue on a test case using Number.toPrecision that I don’t know if it is considered as an incompatibility issue between engines or a real bug example, but according with ES6 specs some values are described as &quot;approximately&quot; maybe this is a case of it. 
V8, JSC and SpiderMonkey returns the wrong value if param &gt; 17, only Chakra works as expected.

Steps to reproduce:
print(123.56.toPrecision(18) === &quot;123.560000000000000&quot;);
print(123.56.toPrecision(18))

Actual results:
False
123.560000000000002

Expected results:
True
123.560000000000000</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1757750</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Shvayka">ashvayka</who>
    <bug_when>2021-05-06 17:46:26 -0700</bug_when>
    <thetext>(In reply to isol2 from comment #0)
&gt; I found an issue on a test case using Number.toPrecision that I don’t know
&gt; if it is considered as an incompatibility issue between engines or a real
&gt; bug example, but according with ES6 specs some values are described as
&gt; &quot;approximately&quot; maybe this is a case of it. 

Thank you for report!

This is most certainly a IEEE 754 precision issue like 0.1 + 0.2 != 0.3.
The spec prose is worded to highlight the inaccuracy: please see step 10.a of https://tc39.es/ecma262/#sec-number.prototype.toprecision.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>