Filtering doubles creates phantom digits

8 posts, 2 answers
  1. Josh
    Josh avatar
    27 posts
    Member since:
    Feb 2012

    Posted 23 Jan 2013 Link to this post

    When filtering a column with values of the double datatype, the filter control appears to append fictitious digits to the values.  This can be observed in Telerik's Unbound demo, http://demos.telerik.com/silverlight/#GridView/UnboundMode

    Looking at the code to see how the data is generated, the possible values for the unit price are 3.0000, 9.0000, 14.0000, 18.4000, 19.0000, 23.2500, 32.0000, 45.6000, and 263.5000.  But then when you filter on Unit Price, the values it displays are radically different.  For example, 18.4000 becomes 18.3999996185303.  Is there anyway around this so the true values are displayed when choosing what to filter on?
  2. Barnes
    Barnes avatar
    17 posts
    Member since:
    May 2012

    Posted 29 Jan 2013 Link to this post

    I am experiencing this too. Please can we get this query answered.

    Thanks in advance
  3. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 31 Jan 2013 Link to this post

    Hello,

    I have opened the demo and checked the values. Indeed there is a value that is displayed as '45,6.' (for example as the values are created randomly) in the cell and when I open the Filtering control it is displayed as '45,599998...' in the DistinctValues list. But when I clicked on it the values were filtered fine. When I entered "45,6" in the first Field Filter, it was filtered fine again.

    Is the way the value is displayed in the DistinctValues list what you experience as a problem?

    All the best,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  4. Barnes
    Barnes avatar
    17 posts
    Member since:
    May 2012

    Posted 31 Jan 2013 Link to this post

    Yes, for me, but I have hijacked this post. The values displayed in the distinct list are not the values displayed the grid.
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 31 Jan 2013 Link to this post

    Hi,

    Thank you for this feedback. We are going to further investigate the case and check why the ListBox inside the FilteringControl displays the values that way. 

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Answer
    Barnes
    Barnes avatar
    17 posts
    Member since:
    May 2012

    Posted 31 Jan 2013 Link to this post

    Incidentally, the problem does not occur when the data type is decimal. I hope this helps you to identify the problem.
  7. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 04 Feb 2013 Link to this post

    Hello,

    You are right. It seems to be a general issue with the double values displayed in the stock Silverlight ListBox.

    What you can do to avoid such inconvenience is to define a StringFormat for the Binding, or a DataFormatString for the column (for example DataFormatString="{}{0:N2}").
     

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  8. Josh
    Josh avatar
    27 posts
    Member since:
    Feb 2012

    Posted 05 Feb 2013 Link to this post

    Not exactly what I wanted to hear.  We're using DataTemplates to display the data, so using DataFormatString won't really work.  But thanks to Barnes for pointing out this issue doesn't exist for Decimal types. 

    Thanks for looking into it Didie.
Back to Top