Page 1 of 1

Math Problem

Posted: Fri Jun 18, 2010 4:42 pm
by MikeC
I need to create an expression that will do a couple things.

I need to take the total number of units, divide by 1000, and then multiply the result by .25.

For example, I have 10,000 units. I need something like {Parcel.[Number Of Units] / 1000 (*.25)} . I'd "like" the .25 to be a variable since I'll use it in several places if that's possible. If not a nested formula would work.

I've been trying everything I can think of and get nothing but errors....

Thanks.

Math Problem

Posted: Mon Jun 21, 2010 12:27 am
by Jan
Hello,

Please try following expression:

Code: Select all

{Parcel.[Number Of Units] / 1000 *0.25}
Please provide error message if it not work.

Thank you.

Math Problem

Posted: Mon Jun 21, 2010 7:59 am
by MikeC
The error that I'm getting when I try that is:

"error CS0019: Operator '*' cannot be applied to operands of type 'decimal' and 'double'.

Math Problem

Posted: Mon Jun 21, 2010 10:57 am
by Ivan
Hello,

Please try following expression:

Code: Select all

{Parcel.[Number Of Units] / 1000M * 0.25M}
Thank you.

Math Problem

Posted: Mon Jun 21, 2010 11:40 am
by MikeC
Ivan wrote:Hello,

Please try following expression:

Code: Select all

{Parcel.[Number Of Units] / 1000M * 0.25M}
Thank you.
Thanks-that appears to work.

For my future reference, can you tell me what adding the M behind the 1000 and .25 does?

Math Problem

Posted: Tue Jun 22, 2010 1:47 am
by Ivan
Hello,
MikeC wrote:For my future reference, can you tell me what adding the M behind the 1000 and .25 does?
Please check the following link: http://msdn.microsoft.com/en-us/library ... 80%29.aspx

Quote:
If you want a numeric real literal to be treated as decimal, use the suffix m or M, for example:

decimal myMoney = 300.5m;

Without the suffix m, the number is treated as a double, thus generating a compiler error.

You can also mix decimal and numeric integral types in the same expression. However, mixing decimal and floating-point types without a cast results in a compilation error.
Thank you.