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

Field Multiplication Problem

6 Answers 109 Views
ExpressionEditor
This is a migrated thread and some comments may be shown as answers.
Gerald
Top achievements
Rank 1
Gerald asked on 17 Jun 2011, 03:23 PM
I have problem multiplying a field by a decimal number. If I multipley a field by a whole number such as 2 it works fine. If I type 2.5 then my expression gets underlined, the result preview is blank and the OK button is grayed out.

I am able to reproduce this problem using the demo on the Telerik site:

http://demos.telerik.com/silverlight/#ExpressionEditor/FirstLook

Try editing the expression in the demo and try multiplying the UnitPrice field by 2.5. The expression looks like this:

 UnitPrice *2.5

Any help with this is greatly appreciated.

Thanks,
-Gerry

6 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 17 Jun 2011, 03:26 PM
Hi Gerry,

 Can you try "UnitPrice * 2,5" instead? 

Regards,
Vlad
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
0
Gerald
Top achievements
Rank 1
answered on 17 Jun 2011, 03:33 PM
We I use  "UnitPrice *2,5" the result is the same as " UnitPrice *2" so the decimal portion is ignored.
0
Accepted
Stefan Dobrev
Telerik team
answered on 17 Jun 2011, 04:07 PM
Hello Gerald,

I'm the guy that has written the parser behind the Expression Editor component. I have just looked at how we handle the decimal separator and here is the exact code from our source:
private static NumberFormatInfo NumberFormatInfo
{
    get
    {
        return NumberFormatInfo.InvariantInfo;
    }
}
 
private static readonly char DecimalSeparator = NumberFormatInfo.NumberDecimalSeparator.FirstOrDefault();

This means that we are using the invariant culture decimal number separator, which is ".". We have done it this way so that a given string expression is valid for all clients no matter of their local machine regional and language settings.

The actual problem in your case is that binary operator (*) is not defined for decimal (UnitPrice field is decimal) and double (2.5 is parsed as double) numbers. If you mouse over the red error underline you will see this problem reported in a tool tip. What we can do under the hood is to create a conversion for the entered double to a decimal number. This will bring a precision lost in some rear cases, but will work in the general case like yours. What you can currently try out is to enter this one: UnitPrice * 2.5e0. This will signal our parser that 2.5 is a decimal number and the runtime will be able to multiply two decimal numbers.

Thanks for bringing this to our attention. Your feedback is greatly appreciated.

Best wishes,
Stefan Dobrev
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
0
Gerald
Top achievements
Rank 1
answered on 17 Jun 2011, 06:50 PM
Thanks, that worked.

Do you know when the fix that you mentioned will be released? We are planning on using the ExpressionEditor in our September release. We would need this fix by then because I don't think that we can expect users to type decimals as 2.5e0 :)

-Gerry
0
Stefan Dobrev
Telerik team
answered on 20 Jun 2011, 01:22 PM
Hello Gerald,

This behavior will be available in one of our next internal releases as well in our upcoming official release of the controls. I have also created a PITS item (#6563) that you can use to track the progress status on your own.

All the best,
Stefan Dobrev
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
0
Nathaniel
Top achievements
Rank 1
answered on 27 Oct 2011, 08:52 PM
What type of Variables do the predefined functions accept? Im trying to use the Pow() function.  It says it takes Number, Numer.  But it wont let me use two of my Fields, which are of type Decimal. 


In the demo  http://demos.telerik.com/silverlight/#ExpressionEditor/FirstLook

I can change the expression column expresiion to be Pow(UnitPrice, UnitPrice).    What is the data type of UnitPrice?

Tags
ExpressionEditor
Asked by
Gerald
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Gerald
Top achievements
Rank 1
Stefan Dobrev
Telerik team
Nathaniel
Top achievements
Rank 1
Share this question
or