Results 1 to 4 of 4

Thread: Ext.Number.toFixed is not stable

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1

    Default Ext.Number.toFixed is not stable

    Repro is at https://fiddle.sencha.com/#fiddle/14m0

    Ext version tested:
    • Ext 6.0.1



    Browser versions tested against:
    • Chrome Version 47.0.2526.111 m



    Description:
    • Ext.Number.toFixed wrongly relies on Chrome's native Number.prototype.toFixed, because Chrome's toFixed is buggy with (0.145).toFixed(2).



    Steps to reproduce the problem:
    • Evaluate Ext.Number.toFixed(0.145, 2) in Chrome



    The result that was expected:
    • "0.15"



    The result that occurs instead:
    • "0.14"

  2. #2

    Default

    Perhaps the issue is related to the fact that as per standard (though weird), 0.145 * 100 results in 14.499999999999998 (in every browser). Though IE handles (0.145).toFixed(2) correctly, resulting "0.15".

  3. #3

    Default

    A next layer of rounding seems to me solving the problem (in Ext.Number.toFixed):

    (Math.round(Math.round(value * pow * 10) / 10) / pow).toFixed(precision)

  4. #4
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985

    Default

    Thanks for the report. We have an existing ticket for this issue (EXTJS-11494).

Similar Threads

  1. Fixing toFixed issue
    By k_cire0426 in forum Ext 5: Q&A
    Replies: 1
    Last Post: 27 Jan 2015, 1:11 PM
  2. Replies: 1
    Last Post: 15 Sep 2013, 11:01 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •