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


  2. Dimiter Topalov
    Dimiter Topalov avatar
    1296 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:

    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:

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