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

Filtering doubles creates phantom digits

7 Answers 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 23 Jan 2013, 07:40 PM
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?

7 Answers, 1 is accepted

Sort by
0
Barnes
Top achievements
Rank 1
answered on 29 Jan 2013, 04:29 PM
I am experiencing this too. Please can we get this query answered.

Thanks in advance
0
Dimitrina
Telerik team
answered on 31 Jan 2013, 01:08 PM
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.

0
Barnes
Top achievements
Rank 1
answered on 31 Jan 2013, 01:10 PM
Yes, for me, but I have hijacked this post. The values displayed in the distinct list are not the values displayed the grid.
0
Dimitrina
Telerik team
answered on 31 Jan 2013, 01:23 PM
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.

0
Accepted
Barnes
Top achievements
Rank 1
answered on 31 Jan 2013, 01:27 PM
Incidentally, the problem does not occur when the data type is decimal. I hope this helps you to identify the problem.
0
Accepted
Dimitrina
Telerik team
answered on 04 Feb 2013, 12:23 PM
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.

0
Josh
Top achievements
Rank 1
answered on 05 Feb 2013, 08:39 PM
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.
Tags
GridView
Asked by
Josh
Top achievements
Rank 1
Answers by
Barnes
Top achievements
Rank 1
Dimitrina
Telerik team
Josh
Top achievements
Rank 1
Share this question
or