Problem in Calculation

Stimulsoft Reports.WEB discussion
Post Reply
G.hammad
Posts: 67
Joined: Tue Jun 24, 2014 7:59 am

Problem in Calculation

Post by G.hammad »

Hello,

I have problem in subtraction of any decimal number and integer number for example in my report :
Quantity Before = 12.3
Quantity After = 12.3 - 12 = 0.30000001 (this is wrong value it must give me 0.3)
and i don't want to apply any custom format

so my question is there any way to solve this problem ?!
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Problem in Calculation

Post by HighAley »

Hello.

Could you specify which our component do you use? What version?
Could you describe step-by-step how to reproduce your issue?

Thank you.
G.hammad
Posts: 67
Joined: Tue Jun 24, 2014 7:59 am

Re: Problem in Calculation

Post by G.hammad »

Hello,

version number :2014.3.17.0
i'm just used Stitext component and make calculation on veriable of type decimal = (12.3 - 12)
and this problem also exist if type of variable is double
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Problem in Calculation

Post by Alex K. »

Hello,

We couldn't reproduce this bug.
Please check the last build and let us know about the result.
Also, please clarify which component do you use - .NET, HTML5, Flash?

Thank you.
G.hammad
Posts: 67
Joined: Tue Jun 24, 2014 7:59 am

Re: Problem in Calculation

Post by G.hammad »

Hello,

this is sample MRT for what happen can you check it please and tell me.
by the way I'm using .Net
thanks alot.
Attachments
WrongCalculation.mrt
(157.53 KiB) Downloaded 222 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Problem in Calculation

Post by Alex K. »

Hello,

This is rounding accuracy in the .NET:
http://stackoverflow.com/questions/1533 ... in-c-sharp

In this case, please try to use the following code:

Code: Select all

decimal PreviousQuantity = 12.3m;
decimal NewQuantity = (-1m * 12m);
decimal TotalQuantity = PreviousQuantity + NewQuantity;
Thank you.
Attachments
02.PNG
02.PNG (5.67 KiB) Viewed 2781 times
01.PNG
01.PNG (6.43 KiB) Viewed 2781 times
G.hammad
Posts: 67
Joined: Tue Jun 24, 2014 7:59 am

Re: Problem in Calculation

Post by G.hammad »

Hello,

thanks for your help :)
but i try to do this by VB language nested of C sharp language but it give me error can't write : decimal or double beforeQuantity
so how i can write same code in vb language nestead of c sharp language?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Problem in Calculation

Post by Alex K. »

Hello,

Please try to use the following code:

Code: Select all

Dim PreviousQuantity As Decimal = 12.3D
Dim NewQuantity As Decimal = (-1D * 12D)
Dim TotalQuantity As Decimal = PreviousQuantity + NewQuantity
Thank you.
G.hammad
Posts: 67
Joined: Tue Jun 24, 2014 7:59 am

Re: Problem in Calculation

Post by G.hammad »

Thanks so much it works in correct way right now :)
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Problem in Calculation

Post by Alex K. »

Hello,

We are always glad to help you!
Let us know if you need any additional help.

Thank you.
Post Reply