Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 10327
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 IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm
No new posts FTP Skip or ignore error and process ... AJAYREDDY All Other Mainframe Topics 3 Wed Sep 27, 2017 8:12 pm
No new posts Assembler Macro Copybook converted to... Ziquilix PL/I & Assembler 4 Tue Sep 26, 2017 3:07 am
No new posts FUSE - IBM MQ - CICS integration error Kevin Vaz CICS 1 Mon Sep 18, 2017 4:31 pm
No new posts Reply MQ open error Vignesh Sid COBOL Programming 6 Thu Sep 07, 2017 6:02 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us