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

negative value in kendo numeric textbox

1 Answer 570 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
Rajish
Top achievements
Rank 1
Rajish asked on 03 Nov 2020, 01:19 PM
I am having a rounding issue with kendo numeric textbox as negative values are not getting rounded off properly. For example, -1.2355 gets displayed as -1.235 instead of -1.236

The configured settings for the said control is as follows:
ReturnValueInputOptions={
max:999999,
min:-999999,
format: 'n3',
decimals: 9
};

If we enter 1.2355 in the numeric textbox, it gets displayed as 1.236, which is fine. 
If we type negative value -1.2355 it gets displayed as -1.235. Is there a way to get this value rounded off and displayed as -1.236

1 Answer, 1 is accepted

Sort by
0
Svet
Telerik team
answered on 05 Nov 2020, 09:43 AM

Hi Rajish,

Thank you for the provided details.

Basically, the reported behavior is caused by the default JavaScript behavior of the Math.round() method that is used by the NumericTextBox component under the hood:

Indeed there isn't a straightforward answer as to how should negative numbers be rounded:

http://mathforum.org/library/drmath/view/71202.html

That is why JavaScript decided to stick to the currently reported behavior, which is used consequently by Kendo UI for Angular as well.

I understand that the current behavior could be disappointing, but it is caused by a limitation of JavaScript as opposed to being a Kendo UI for Angular related feature or specific functionality.

I hope the provided information helps. Please let me know in case any further information is required for this case. Thank you.

Regards,
Svetlin
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
NumericTextBox
Asked by
Rajish
Top achievements
Rank 1
Answers by
Svet
Telerik team
Share this question
or