View previous topic :: View next topic
|
Author |
Message |
jkri
New User
Joined: 24 Jul 2007 Posts: 17 Location: pune
|
|
|
|
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 |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
You could use the RIGHT function
Code: |
RESULT = RIGHT(sum,2,'0')
say RESULT |
Garry |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
RIGHT |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
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 |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
- What does this have to do with absolute values?
- 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. |
|
Back to top |
|
|
jkri
New User
Joined: 24 Jul 2007 Posts: 17 Location: pune
|
|
|
|
Thanks Garry. |
|
Back to top |
|
|
jkri
New User
Joined: 24 Jul 2007 Posts: 17 Location: pune
|
|
|
|
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 |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
You being the following :
Occupation: software engineer
Mainframe Skills: cobol,jcl,rexx,db2,cics
Couldnt you find out that for yourself? |
|
Back to top |
|
|
|