This is a migrated thread and some comments may be shown as answers.

Numeric Text Box in angular adds more decimals after 0.06

1 Answer 32 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
Shameer
Top achievements
Rank 1
Shameer asked on 01 Dec 2016, 08:13 PM

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

 

1 Answer, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 05 Dec 2016, 11:09 AM
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.
Tags
NumericTextBox
Asked by
Shameer
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question
or