Math Problem

Stimulsoft Reports.NET discussion
Post Reply
MikeC
Posts: 51
Joined: Mon Jun 07, 2010 3:36 pm

Math Problem

Post 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.
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Math Problem

Post 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.
MikeC
Posts: 51
Joined: Mon Jun 07, 2010 3:36 pm

Math Problem

Post 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'.
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Math Problem

Post by Ivan »

Hello,

Please try following expression:

Code: Select all

{Parcel.[Number Of Units] / 1000M * 0.25M}
Thank you.
MikeC
Posts: 51
Joined: Mon Jun 07, 2010 3:36 pm

Math Problem

Post 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?
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Math Problem

Post 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.
Post Reply