Bug? NumberOfDecimalDigits affects actual value

2 posts, 0 answers
  1. Alessandro
    Alessandro avatar
    4 posts
    Member since:
    Feb 2011

    Posted 31 Mar 2011 Link to this post

    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:

    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.

  2. Yana
    Yana avatar
    4604 posts

    Posted 04 Apr 2011 Link to this post

    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,
    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
Back to Top