# Round Function in axapta

Hi Friends,

static void Job9(Args _args)
{
real a,b,c,d,e;
;
a=2991.93;
b=Round(((a100)/104.944),0.01);
c=Round(((b
4.80)/100),0.01);
d=Round(((c2)/100),0.01);
e=Round(((c
1)/100),0.01);

info(strfmt(’%1’,a));
info(strfmt(’%1’,b));
info(strfmt(’%1’,c));
info(strfmt(’%1’,d));
info(strfmt(’%1’,e));

}

problem is after calucaltion,the total sum is not equal

we have to equal a=b+c+d+e

but it is not equal.some 0.01 difference is coming

Murali

Hi Murali ,

U can use DecRound() function it may solve your issue.

Regards,

Phani.

You’re accumulating rounding errors through your calculation. You’ll get much preciser result by not rounding the number in each step - round the final result only.

Hi phani,

Thanks for reply.I already used DecRound() function still it showing same error

Murali

Hi martin,

Actually,problem is

a is debit amount and (b+c+d+e) is credit amount so while posting both credit amount and debit amount must and should equal but after calculation these are not equal…

can u provide the solution…

Murali

I already told you what to do. But all right, I’ll give you a demonstration:

``````real a,b,c,d,e;
;

a = 2991.93;
b = round((a*100)/104.944,0.01);
c = round((b*4.80)/100,0.01);
d = round((c*2)/100,0.01);
e = round((c*1)/100,0.01);

// Difference: -0.01
info(strFmt("Difference: %1", (a-(b+c+d+e))));

a = 2991.93;
b = (a*100)/104.944;
c = (b*4.80)/100;
d = (c*2)/100;
e = (c*1)/100;

// Difference: 0.00
info(strFmt("Difference: %1", (a-(b+c+d+e))));
``````

Hi martin,

Thanks for reply. but still it is coming 0.01 difference.

``````a = 2991.93;
b = (a*100)/104.944;    //  b=2850.98
c = (b*4.80)/100;           // c=136.85
d = (c*2)/100;                // d=2.74
e = (c*1)/100;               // e =1.37

a =2991.93    b+c+d+e=2991.94

so difference is 0.01