Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Deduction rounding off error

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Deduction rounding off error
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10274
Location: italy

PostPosted: Thu May 05, 2011 2:22 pm    Post subject: Reply to: rounding off error
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Thu May 05, 2011 2:45 pm    Post subject: Re: rounding off error
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    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Thu May 05, 2011 3:26 pm    Post subject: Reply to: rounding off error
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DB2 Program abending without giving a... rahulgarg14 DB2 7 Mon May 29, 2017 8:10 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts IDC2902I Error tzeche ABENDS & Debugging 2 Tue Mar 28, 2017 11:39 am
No new posts Need help with below DB2 error ashek15 DB2 3 Sat Mar 18, 2017 5:56 am
No new posts FINDREP Syntax Error seahawk789 DFSORT/ICETOOL 4 Thu Mar 09, 2017 10:11 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us