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

Bug? NumberOfDecimalDigits affects actual value

1 Answer 60 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Alessandro
Top achievements
Rank 1
Alessandro asked on 31 Mar 2011, 01:45 PM
Hi All,

we're evaluating the Telerik Suite of controls for our products. While testing your RadNumericUpDown, I found a rather serious issue (or so it seems): setting the NumberOfDecimalDigits actually rounds the inner value to that precision. I am expecting that the value stays the same and the aforementioned property only affects the DISPLAY of that value.

Code to reproduce:

[Test]
public void Value_NumberDecimalDigitsIsLessThanPrecision_IsNotModified()
{
    _nud.NumberFormatInfo.NumberDecimalDigits = 3;
    _nud.Value = 100.12345;
    _nud.NumberFormatInfo.NumberDecimalDigits = 0;
    Assert.That(_nud.Value, Is.EqualTo(100.12345));
}

this unit test fails with:

Expected: 100.12345000000001d
But was:  100.123d

this means that the value gets immediately truncated to the NumberOfDecimalDigits and then further changes to NumberOfDecimalDigits do not modify it anymore... Really odd!

Can you tell me more about this?

Thanks a lot.

Alessandro

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 04 Apr 2011, 02:59 PM
Hi Alessandro,

Thank you for your interest in RadControls for Silverlight.

Actually this behavior of RadNumericUpDown is by design - the reason for this is to avoid showing a wrong value in the control (because when NumberOfDecimalDigits is set, the value is rounded).

We  hope that this is not a major show-stopper for you.

All the best,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
NumericUpDown
Asked by
Alessandro
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or