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

Issue with number formatting with a custom format "#,##0.00##"

1 Answer 154 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
martijn
Top achievements
Rank 1
martijn asked on 07 May 2013, 02:49 PM
We have a need to for decimal formatting with a minimum of 2 decimals and a maximum of 4. However there's a 'small' rounding bug.

This:
kendo.toString(1.23126, "#,##0.00##")

Returns:
1.2313
(as expected)

However, this:
kendo.toString(1.23125, "#,##0.00##")

Returns:
1.2312

Which is clearly not expected. Because when you do this:
kendo.toString(1.235, "#,##0.00")

It returns:
1.24

This was tested using Chrome 26.somthing :)

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 09 May 2013, 08:49 AM
Hello,

 
Here is a quote from answer to the ticket opened on the same subject:

Thank you for contacting us. The described behavior is actually caused by Chrome itself. Under the hood kendo.toString uses Number.toFixed. It seams that Number.toFixed method uses different rounding methods depending on the fraction length. We will address this issue in order to overcome this inconsistency (next release is due the mid of May). For now you can round number manually before pass it to toString method. I updated your Telerik points because of the involvement.


Regards,

Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
General Discussions
Asked by
martijn
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or