Sandeep Kushwah
Sandeep Kushwah

Reputation: 592

Decimal value rounding issue in knockout

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?

Upvotes: 2

Views: 503

Answers (1)

Roy J
Roy J

Reputation: 43899

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.

Upvotes: 1

Related Questions