IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Absolute value of number


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jkri

New User


Joined: 24 Jul 2007
Posts: 17
Location: pune

PostPosted: Fri Nov 27, 2009 2:43 pm
Reply with quote

I have a small query.

I need to calculate sum of 2 numbers.
eg - A = 02, B = 03 ; sum = A+B = 05.

Is it possible to display the sum as 05 instead of 5? Is there any arithemetic function available for that?
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Fri Nov 27, 2009 2:53 pm
Reply with quote

You could use the RIGHT function

Code:
  RESULT = RIGHT(sum,2,'0')
  say  RESULT


Garry
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Nov 27, 2009 2:53 pm
Reply with quote

RIGHT
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Fri Nov 27, 2009 2:54 pm
Reply with quote

Well you are not giving any hint of the kind of language you are
going to use, but you can use SAS for that kind of things.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Fri Nov 27, 2009 2:58 pm
Reply with quote

  1. What does this have to do with absolute values?
  2. How do you decide if there should be one zero before the five, rather than three or 42?


Code:

/* REXX */
trace ?r
a = 02
b = 03
sum = right(a + b, max(c2d("L==2"), length(a + b), length(a), length(b)), '0')
say sum


Don't remove the "trace ?r", it will show you exactly what is happening. Enjoy. icon_lol.gif
Back to top
View user's profile Send private message
jkri

New User


Joined: 24 Jul 2007
Posts: 17
Location: pune

PostPosted: Fri Nov 27, 2009 3:00 pm
Reply with quote

Thanks Garry.
Back to top
View user's profile Send private message
jkri

New User


Joined: 24 Jul 2007
Posts: 17
Location: pune

PostPosted: Fri Nov 27, 2009 3:07 pm
Reply with quote

Prino,

Nothing with the absolute value. Sorry for the misleading subject line.

My code is doing some update to a list of members whose name ends with number (2 digits) and there are around 80 members. So to get the next member I am adding the current memebr name by 1. So for first 9 members I need to get the value as 01,02..09, for rest it doesnt matter .

Just wanted to know if there are any functions. Thanks for the reply.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Fri Nov 27, 2009 3:17 pm
Reply with quote

You being the following :

Occupation: software engineer
Mainframe Skills: cobol,jcl,rexx,db2,cics

Couldnt you find out that for yourself?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Increase the number of columns in the... IBM Tools 3
No new posts Cobol program with sequence number ra... COBOL Programming 5
Search our Forums:

Back to Top