2

When I try to bind decimal value greater than 17 digits in length to knockout observable property, I am facing uneven behaviour of knocukout.

Explanation of issue: We are entering 12345678987654321 value with decimal at different places. Case 1 : if value is 123456789.87654321 it results = 123456789.87654321
Case 2 : if value is 1234567.8987654321 it results = 1234567.8987654322
Case 3 : if value is 12345678.987654321 it results = 12345678.98765432
Case 4(without decimal) : if value is 12345678987654321 it results = 12345678987654320.
Please see the comments for the JS fiddle link.

Any suggestions? or any Javascript or any knockout property we can apply to avoid this uneven behaviour?

Sandeep Kushwah
  • 590
  • 1
  • 18
  • 35
  • Fiddle link for the issue : http://jsfiddle.net/LkqTU/26669/ – Sandeep Kushwah Sep 10 '15 at 12:07
  • 1
    Possible duplicate of: http://stackoverflow.com/questions/1086575/how-can-i-handle-numbers-bigger-than-17-digits-in-firefox-ie7 – Dandy Sep 10 '15 at 12:33
  • @Dandy : That solutions seems quite old and don't we have a property in knockout to overcome the issue? Even it results properly for case 1. So looking for some work around to other cases. – Sandeep Kushwah Sep 10 '15 at 12:52

1 Answers1

1

Knockout isn't concerned with fixing all JavaScript shortcomings. It exists to get your data model out of your view. For other problems, you need to look at other solutions. Some math libraries are discussed here.

Roy J
  • 42,522
  • 10
  • 78
  • 102