## How to get decimal places?

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

### How to get decimal places?

Hi,

I ran below SORT but getting rounded value (known thing) and expecting to get 500.75".

//STEP0001 EXEC PGM=SORT
//SORTIN   DD *
2004
//SORTOUT  DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SYSIN    DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(10:1,4,ZD,DIV,+4))

Output:
********************************* TOP OF DATA **********************************
2004                 501
******************************** BOTTOM OF DATA ********************************

Expected Output:
********************************* TOP OF DATA **********************************
2004                 500.75
******************************** BOTTOM OF DATA ********************************

Thanks.
ranga_subham

Posts: 279
Joined: Fri Jul 18, 2008 7:46 pm
Has thanked: 0 time
Been thanked: 1 time

### Re: How to get decimal places?

2004 divided by 4 is 501.

501 multiplied by 4 is 2004.

So your example is poor. We'll assume 2003.

Sort does not do "rounding". If you want rounding, you have to code it yourself.

Sort does not know about implied decimal places. If you want a result of 50075 then you have to make the value to be divided 200300. You then use an EDIT to give you the decimal places you want.
BillyBoyo
Global moderator

Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

### Re: How to get decimal places?

Your arithmetic teacher should be tarred, feathered, hanged and left on the gallows until it rots
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: 2692
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 138 times

### Re: How to get decimal places?

Yes Bill.....it was 2003 .....what if I have more different values instead of one input record?

Thanks.
ranga_subham

Posts: 279
Joined: Fri Jul 18, 2008 7:46 pm
Has thanked: 0 time
Been thanked: 1 time

### Re: How to get decimal places?

Bill, am I right with this code? Got results though

//*====================================================================*
//STEP0001 EXEC PGM=SORT
//SORTIN   DD *
2003
2005
//SORTOUT  DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SYSIN    DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(10:1,4,ZD,MUL,+100,DIV,+4,EDIT=(TTT.TT)))
//*

Thanks.
ranga_subham

Posts: 279
Joined: Fri Jul 18, 2008 7:46 pm
Has thanked: 0 time
Been thanked: 1 time

### Re: How to get decimal places?

Yes, that is one way to do it. Do you know how it works, given that you are starting with only four bytes?

OVERLAY=(15:C'00',10:1,6,ZD,DIV,+4,EDIT=(TTT.TT)))

Would be another.
BillyBoyo
Global moderator

Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

### Re: How to get decimal places?

Thanks Bill.......nice idea
ranga_subham

Posts: 279
Joined: Fri Jul 18, 2008 7:46 pm
Has thanked: 0 time
Been thanked: 1 time

### Re: How to get decimal places?

Bill, all attempts with your suggested code end with S0C7
ranga_subham

Posts: 279
Joined: Fri Jul 18, 2008 7:46 pm
Has thanked: 0 time
Been thanked: 1 time

### Re: How to get decimal places?

Sorry, 15 should have been 5 It is adding the two zeros to your input.

Better, perhaps, so is not there permanently

OVERLAY=(10:1,4,C'00',10:10,6,ZD,DIV,+4,EDIT=(TTT.TT)))
BillyBoyo
Global moderator

Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

### Re: How to get decimal places?

ran it with latest code and got the results
ranga_subham

Posts: 279
Joined: Fri Jul 18, 2008 7:46 pm
Has thanked: 0 time
Been thanked: 1 time