Numeric Text Box in angular adds more decimals after 0.06

2 posts, 0 answers
  1. Shameer
    Shameer avatar
    2 posts
    Member since:
    Feb 2016

    Posted 01 Dec 2016 Link to this post

    we are using kendo numeric text box in our angular js project.

    it adds more decimal place ,when we increment the values from 0.06 to 0.07

    http://dojo.telerik.com/aZAQU/2

     

  2. Dimiter Topalov
    Admin
    Dimiter Topalov avatar
    1274 posts

    Posted 05 Dec 2016 Link to this post

    Hello Shameer,

    The described behavior is caused by the IEEE 754 standard used by JavaScript for representing floating point numbers, and is beyond our control:

    http://blog.chewxy.com/2014/02/24/what-every-javascript-developer-should-know-about-floating-point-numbers/#IEEE_754

    For example: 

    console.log(0.06 + 0.01) // 0.06999999999999999
     
    console.log(0.1 + 0.2) // 0.30000000000000004

    In theory, you can use the Kendo UI NumericTextBox spin event handler, and set precision to the widget's value, but this workaround does not fully cope with the limitations, described in the beginning:

    http://dojo.telerik.com/aZAQU/6

    Regards,
    Dimiter Topalov
    Telerik by Progress
    Kendo UI is ready for Visual Studio 2017 RC! Learn more.
Back to Top