How to get decimal places?



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

How to get decimal places?

Postby ranga_subham » Thu Nov 15, 2012 5:08 pm

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 ********************************


Please help.

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?

 

Re: How to get decimal places?

Postby BillyBoyo » Thu Nov 15, 2012 5:19 pm

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?

Postby enrico-sorichetti » Thu Nov 15, 2012 5:25 pm

:shock:

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

Re: How to get decimal places?

Postby ranga_subham » Thu Nov 15, 2012 5:55 pm

Yes Bill.....it was 2003 :oops: .....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?

Postby ranga_subham » Thu Nov 15, 2012 6:09 pm

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?

Postby BillyBoyo » Thu Nov 15, 2012 7:07 pm

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?

Postby ranga_subham » Thu Nov 15, 2012 9:29 pm

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?

Postby ranga_subham » Thu Nov 15, 2012 9:38 pm

Bill, all attempts with your suggested code end with S0C7 :o
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?

Postby BillyBoyo » Thu Nov 15, 2012 9:44 pm

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?

Postby ranga_subham » Thu Nov 15, 2012 9:49 pm

ran it with latest code and got the results :D
ranga_subham
 
Posts: 279
Joined: Fri Jul 18, 2008 7:46 pm
Has thanked: 0 time
Been thanked: 1 time


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post