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.
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…
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))));
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
please check it..
Thanks in advance
Murali
Your calculation is wrong. Take the first step, for example: (2991.93 * 100) / 104.944 = 2850.97766427809… Your result, 2580.98, is not correct, therefore the final result is not correct either.