IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Deduction rounding off error


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sobankumar ilango

New User


Joined: 05 May 2011
Posts: 3
Location: canada

PostPosted: Thu May 05, 2011 2:00 pm
Reply with quote

deduction amount = 558.71

there are two children CS1 and CS2 both of them are expected to get CS1=279.35 and CS2=279.36

during calculation am using ( compute) values are getting rounded off to 279.36 and 279.36

ie it is actually exceeding the deduction amount

279.36+279.36=558.72
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu May 05, 2011 2:22 pm
Reply with quote

in general for rounding issues for financial/IR processes
ask Your organization to inquire at the IR offices about the standard/approved ways of carrying on the computations

in Italy for example the computations must be carried on with 4 decimal digits and displayed with two

let' s not quarrel that sometimes there might be differences,
but in my numbers(apple equivalent of excel ) worksheet after I made the changes everything has been checking out properly for qite a few years.

the best way is to ask the powers that be !

anyway for the particular case You are out of luck
dividing by two and rounding even with the proper rules it will alway result in an arithmetic mismatch
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu May 05, 2011 2:45 pm
Reply with quote

sobankumar ilango wrote:
deduction amount = 558.71

there are two children CS1 and CS2 both of them are expected to get CS1=279.35 and CS2=279.36

during calculation am using ( compute) values are getting rounded off to 279.36 and 279.36

ie it is actually exceeding the deduction amount

279.36+279.36=558.72


To get your specific result, where the remainder is allocated to a specific place, don't use ROUNDED.

You can use DIVIDE x BY y GIVING z REMAINDER a (sorry, bad planning).

Then add the "a" to the required field.

If you want to do it with COMPUTE, don't do the rounding, let it truncate, then subtract everything from the original amount and put whatever is left after this into your specific place.
Back to top
View user's profile Send private message
sobankumar ilango

New User


Joined: 05 May 2011
Posts: 3
Location: canada

PostPosted: Thu May 05, 2011 3:15 pm
Reply with quote

thanks for the reply..I think I should make myself more clear..
the program selects the dependents(children in this case)
in a pro ration manner IE one by one and processes until the dependents are zero.( dependents are not always two).

I cannot get rid of round up option ( also it wont help)..

is there a solution for this problem ?

someone plzzzzzzzz help me !!!!!!
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Thu May 05, 2011 3:24 pm
Reply with quote

two algorythms :
1 ) give the last one , what ever is left.
suppose deduction = 20 ; dependents = 3
1st : 20. / 3 = 6.67
2nd: 20. / 3 = 6.67
3th: 20 - 6.67 - 6.67 = 6.66

2) remember leftovers.
1st: 20 / 3 = 6.67 => left = 13.33 / 2
2nd: 13.33 / 2 = 6.67 => left = 6.66 / 1
3th: 6.66 / 1 = 6.66
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu May 05, 2011 3:26 pm
Reply with quote

It doesn't matter how many you divide by, what matters is you know where the "balancing" part is to go.

Why do you think you can't get rid of the rounding? If you have to keep it, you have to work "upside down", in that you have to subtract your balancing item, and the specific place you want it to go will be less than all the others, not greater.

Divide Money-amount by Number-of-dependents giving Amounts-which-are-equal-per-dependent remainder Balancing-amount-which-is-not-equally-divisible (might be zero at times, won't ever be very big).

Each dependent gets Amounts-which-are-equal-per-dependent and one (your choice which) gets Amounts-which-are-equal-per-dependent plus Balancing-amount-which-is-not-equally-divisible.

Try it out, at least, then tell me your problems with the result.
Back to top
View user's profile Send private message
sobankumar ilango

New User


Joined: 05 May 2011
Posts: 3
Location: canada

PostPosted: Thu May 05, 2011 6:01 pm
Reply with quote

hi BILL I owe u big thanks ... the logic given by you is working ...
thanks everyone ... thanks for the time
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Error while running web tool kit REXX... CLIST & REXX 5
No new posts Getting Error while trying to establi... DB2 3
Search our Forums:

Back to Top