Rounding issue after computation



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

Rounding issue after computation

Postby sumeendar » Thu Nov 27, 2014 6:53 pm

i have a Zoned decimal field (start pos 31, length 9) in file, where i need to divide this field by 1000 and rounded.

using the below Syncsort syntax i could achieve it, but there is an issue with rounding.

31,9,ZD,DIV,+1000,ZD,LENGTH=9

for eg, For value 00000487C (000004873), after the above arithmetic operation, i am getting it rounded as 4.
Since 000004873/1000 gives 4.87 (more than 4.50), I need to round it to 5.

let me know what else need I need to do to achive this

Thanks
sumeendar
 
Posts: 6
Joined: Fri Apr 13, 2012 5:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Rounding issue after computation

Postby enrico-sorichetti » Thu Nov 27, 2014 7:08 pm

how would You do it by pencil and paper ???
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Rounding issue after computation

Postby BillyBoyo » Thu Nov 27, 2014 7:35 pm

Since SORT does not do rounding, why do you think you are getting it "rounded as 4"?

If you need rounding, you have to code it yourself. Something like this (untested):

  INREC IFTHEN=(WHEN=(37,1,CH,GE,C'5'),
                   OVERLAY=(31:3Z,31,6,ZD,ADD,+1,LENGTH=6)),
        IFTHEN=(WHEN=NONE,
                   OVERLAY=(31:3Z,31,6))


The 3Z will put three zoned-decimal zeros in the first three positions of your field. The first IFTHEN will add one to the first six digits of your source number and store the result after the three zeros. The second, like an ELSE, will just store the first six digits after the three zeros.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Rounding issue after computation

Postby steve-myers » Thu Nov 27, 2014 9:01 pm

Assuminng 00000487C is hexadecimal, it is not "zoned decimal." It is packed decimal.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Rounding issue after computation

Postby sumeendar » Thu Nov 27, 2014 9:53 pm

00000487C is zoned decimal value itself. The input field is zoned decimal format
sumeendar
 
Posts: 6
Joined: Fri Apr 13, 2012 5:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Rounding issue after computation

Postby steve-myers » Fri Nov 28, 2014 6:07 am

OK. After I put up my post, I realized there was a good chance I goofed. I let my fingers get into trouble before thinking.

I'm pretty sure 000004873/1000 = 4. The remainder is dropped and lost. However, I don't use Syncsort, and it's not in the environment I use, so I can't be sure about that.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post