Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Round up using DFSORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
kellaurin

New User


Joined: 14 Apr 2009
Posts: 11
Location: Sacramento, CA

PostPosted: Tue Apr 14, 2009 11:35 pm    Post subject: Round up using DFSORT
Reply with quote

I want to calculate a percentage for a number but the result is always rounding down. Here is my statement:

24:(24,9,ZD,MUL,+8605,DIV,+10000),M18,LENGTH=9,

This is the value of my input field: 00000458B
This is the value of my output field: 39.42

I want it to be 39.43 by rounding the actual result of 39.42811.

Any help would be appreciated.
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Tue Apr 14, 2009 11:50 pm    Post subject:
Reply with quote

I believe DFSORT control statements like the following will do the rounding up you want:

Code:

  OPTION COPY                                                   
  INREC BUILD=(24:(((24,9,ZD,MUL,+8605),ADD,+5000),DIV,+10000), 
     M18,LENGTH=9)                                               
Back to top
View user's profile Send private message
kellaurin

New User


Joined: 14 Apr 2009
Posts: 11
Location: Sacramento, CA

PostPosted: Wed Apr 15, 2009 12:24 am    Post subject:
Reply with quote

Thanks for the fast reply Frank, that worked perfectly. So basically DFSORT rounds down, so I have to trick it by adding .5 to every number before the final result rounds down?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Apr 15, 2009 12:42 am    Post subject:
Reply with quote

Yes, that's correct.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Wed Apr 15, 2009 1:35 am    Post subject:
Reply with quote

Rounding down might be an inaccurate description. I'd guess that "truncating" would be a better description. And Frank's technique can be used any time a result is being truncated because of the lack of a "rounding" function. Simply add 5 to the digit position that is being truncated (the digit immediately to the right of the one you want to round to).
Back to top
View user's profile Send private message
kellaurin

New User


Joined: 14 Apr 2009
Posts: 11
Location: Sacramento, CA

PostPosted: Wed Apr 15, 2009 7:31 pm    Post subject:
Reply with quote

Good point on the truncating, not rounding down. Thanks Terry.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Apr 15, 2009 8:58 pm    Post subject:
Reply with quote

Terry,

DFSORT does integer arithmetic. The decimal places are not kept for the result of a divide. Is that what you mean by "truncating"?
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Wed Apr 15, 2009 10:12 pm    Post subject:
Reply with quote

I guess so. I was just trying to better distinguish between the terms "rounding down" and "truncating".
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DFSORT - Overriding default option TU... Steve Ironmonger DFSORT/ICETOOL 3 Tue Apr 04, 2017 3:54 pm
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts DFSORT sorting only specific records akodakka DFSORT/ICETOOL 4 Thu Aug 04, 2016 11:24 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us