If I type the maximum value for a decimal (79228162514264337593543950335) and then try to increase the number through the arrow buttons, I get the following exception:
System.OverflowException: Value was either too large or too small for a Decimal.
The behavior is reproducible with or without setting the Max parameter to decimal.MaxValue: https://blazorrepl.telerik.com/mSuFwebI299wPCzV25.
Hi Patrik,
We discussed this case with the design team and decided to handle the exception by restricting the overflow behavior of the NumericTextBox for all data types. The end user does not expect the value to overflow when it reaches the maximum value of the bound data type.I look forward to hearing back from you.
Regards,
Tsvetomir
Progress Telerik
Do you have a stake in the designеr-developer collaboration process? If so, take our survey to share your perspective and become part of this global research. You’ll be among the first to know once the results are out.
-> Start The State of Designer-Developer Collaboration Survey 2024
Hi Tsvetomir,
Here are answers for your questios:
Regards
Patrik
Hi Patrik,
I understand your concerns. The reason for this behavior is that in our source code, we first attempt to increment the value and then clamp it to the maximum if needed.
Additionally, we are constantly trying to improve our product, and I would like to gather more information about this specific case with the following questions:
Answering these questions will provide us with better insight into this scenario and help us make a more informed decision.
Regards,
Tsvetomir
Progress Telerik
However, this behavior doesn't reflect the numeric box correctly. If the numeric box has a Max
parameter with a value type of decimal, it's logical that if the user clicks on the arrows to increase the number and the current input value is equal to the Max
value of the parameter, the value should not increase further.
For example: If my Max
value is 10 and the input already shows 10, then when I use the arrow to increase the number, the input should still display 10 (the Max
value). Why doesn't this happen for decimal.MaxValue
?
Is it really that difficult to implement logic in the NumericTextBox
component to check the Max
parameter (and similarly the Min
parameter) so that if the input value reaches the Max
, it stays at the Max
value instead of throwing an exception?
Hello all,
After a discussion with the dev team regarding potential improvements and recent research on handling decimal overflow, we are planning to maintain the current behavior. The reason is that the existing behavior follows Microsoft's specifications and prevents the potential precision loss associated with silently managing decimal overflow. This ensures our NumericTextBox component maintains accuracy and compatibility with established standards across various platforms and systems.
For further understanding, you can refer to the Microsoft official documentation on floating-point arithmetic overflow, which details this decimal behavior here. Additionally, to see a practical demonstration of decimal overflow, where a standalone decimal (outside of a NumericTextBox component) reaches MaxValue during incrementation and throws an error, please visit this REPL example.
Following the above, we would be interested in seeing examples of real-life cases where the end-user overflows the Numeric input. If anyone has such examples or additional feedback, we would be happy to review and consider them.
Regards,
Tsvetomir
Progress Telerik