## Rounding issue after computation

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

### Rounding issue after computation

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

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: 2979
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 160 times

### Re: Rounding issue after computation

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

Assuminng 00000487C is hexadecimal, it is not "zoned decimal." It is packed decimal.
steve-myers
Global moderator

Posts: 2106
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 242 times

### Re: Rounding issue after computation

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

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: 2106
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 242 times

Return to Syncsort/Synctool

• Related topics
Replies
Views
Last post