rexx , formatting question

2005-06-29 Thread Daniel Cremieux
dear gurus,

a=15.53666222

How to display only the 2 first decimal digit :

=> a=15.53 (or 15.54 i don't mind for the precision)

Thank you

another question :
a=1555666
is there any way to display it as 1.555.666 ( easier to read)


great thanks

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: rexx , formatting question

2005-06-29 Thread Perryman, Brian
Daniel

Take a look a the FORMAT built-in function.

In your case I think a = FORMAT(a,,2) should do what you want.

Brian

-Original Message-
From: IBM Mainframe Discussion List [mailto:[EMAIL PROTECTED]
Behalf Of Daniel Cremieux
Sent: 29 June 2005 17:05
To: IBM-MAIN@BAMA.UA.EDU
Subject: rexx , formatting question


dear gurus,

a=15.53666222

How to display only the 2 first decimal digit :

=> a=15.53 (or 15.54 i don't mind for the precision)

Thank you

another question :
a=1555666
is there any way to display it as 1.555.666 ( easier to read)


great thanks

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html
This e-mail message is for the sole use of the intended recipient(s)and may 
contain confidential and privileged information of Transaction NetworkServices. 
 
Any unauthorized review, use, disclosure or distribution isprohibited.  If you 
are not the intended recipient, please contact thesender by reply e-mail and 
destroy all copies of the original message.

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: rexx , formatting question

2005-06-29 Thread McKown, John
> -Original Message-
> From: IBM Mainframe Discussion List 
> [mailto:[EMAIL PROTECTED] On Behalf Of Daniel Cremieux
> Sent: Wednesday, June 29, 2005 11:05 AM
> To: IBM-MAIN@BAMA.UA.EDU
> Subject: rexx , formatting question
> 
> 
> dear gurus,
> 
> a=15.53666222
> 
> How to display only the 2 first decimal digit :
> 
> => a=15.53 (or 15.54 i don't mind for the precision)

You're so close. Use the FORMAT function.

twoplaces=format(data,,2)

> 
> Thank you
> 
> another question :
> a=1555666
> is there any way to display it as 1.555.666 ( easier to read)

I don't know a really good way, but the following should work:

b=""
do while length(a) > 3
   if b=""
   then b=right(a,3) /* get last 3 digits of a */
   else b=right(a,3)"."b /* current last 3 digits of a with previous
"tail" */
   a = left(a,length(a)-3) /* remove last 3 digits of a */
end
if a <> "" then b=a"."b

Note that you may end up with a trailing period if "a" has 3 or fewer
digits.

> 
> 
> great thanks
> 


--
John McKown
Senior Systems Programmer
UICI Insurance Center
Information Technology

This message (including any attachments) contains confidential
information intended for a specific individual and purpose, and its'
content is protected by law.  If you are not the intended recipient, you
should delete this message and are hereby notified that any disclosure,
copying, or distribution of this transmission, or taking any action
based on it, is strictly prohibited.

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: rexx , formatting question

2005-06-29 Thread Arthur T.
On Wed, 29 Jun 2005 18:59:52 GMT, in bit.listserv.ibm-main 
(Message-ID:<[EMAIL PROTECTED]>) "gerard46" 
<[EMAIL PROTECTED]> wrote:



|> another question :
|> a=1555666
|> is there any way to display it as 1.555.666 ( easier to read)

| I don't know a really good way, but the following should work:
|
| b=""
| do while length(a) > 3
|   if b=""
|   then b=right(a,3) /* get last 3 digits of a */
|   else b=right(a,3)"."b /* current last 3 digits of a 
with previous

| "tail" */
|   a = left(a,length(a)-3) /* remove last 3 digits of a */
| end
| if a <> "" then b=a"."b
|
| Note that you may end up with a trailing period if "a" 
has 3 or fewer

| digits.

 or if the number is in exponential notation
 (4.567e+77 ===> 4.567e,+77)

or has a leading sign
 (-123 ===>  -,123 ---or---.+56 ===>  +,456)

or has a decial point
 ( .1234  ===> .1,234---or---   123. ===> 1,23.)

or has leading or trailing blanks  ( +  23 > +  , 23)

... and I'm sure that there are a few others. 
_Gerard S.


 The following code was designed for a specific size 
of numbers, but works fine for them.  The comments should 
allow someone to make the code work for other (or variable) 
lengths.  I probably could, too, but I don't want to have 
to test it.  The code also knows when to give up.  It was 
copied from my CALCR exec, available on the CBT tape (file 209).


 You might also want to ask on the REXX listserv 
and/or one of the REXX newsgroups.  I know there are more 
elegant ways to do this.


 Also note that this is for the USA, where we use 
commas to separate triads and period for decimal point.


INITIALIZE:
   NUMERIC DIGITS 30
   !!max = 
   !!min = -999
   !!minfrac = 10**-33  /* Smallest number I'll express without
   going to scientific notation  */


COMMA: /* put commas into number and format it correctly */
   procedure expose !!max !!min  !!minfrac
   curr = arg(1)
   select
 when abs(curr) < !!minfrac & curr \= 0 then
   return format(curr16)
 when curr > !!max then
   return ' ' || format(curr,,29,,20)
 when curr < -1*!!max/10 then  /* neg numbers have 
xtra char */

   return format(curr,,29,,19)
 when abs(curr) < !!min then
   return format(curr,,29,,20)
 otherwise
   nop
   end /* of select */
   int = trunc(curr)
   fraction = format(curr - int,,,0)
   if int = '' then int = 0
   int = format(int,20)
   /*  17 = 20-3  */
   do i = 17 to 1 by -3 while datatype(substr(int,i,1),'N')
 int = insert(',',int,i)
   end
   int = right(int,26) /* 26 = 20 + int((20-1)/3) */
   select
 when fraction = '' then nop
 when fraction = 0 then fraction = ''
 otherwise nop
   end   /* of select */
   if length(fraction) > 0 then do
 parse var fraction . '.' fraction
 fraction = '.'fraction
   end /* of IF */
   if int = 0 then
 if curr < 0 then int = right('-0',26)
   ret = int || fraction
   return ret

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: rexx , formatting question

2005-06-29 Thread Mark L. Wheeler
If you happen to have CMS/TSO Pipelines, you can try this:
   a  = 123456.789   /* Perhaps */
   a2 = format(a,,2)
   'PIPE()',
  'VAR A2 |',
  'SPECS A: 1-* .',
'SET #0:=A',
'PRINT #0 PICTURE ZZZ,ZZZ,ZZZ,ZZZ.99 1 |',
  'STRIP LEADING |',
  'VAR A2_WITH_COMMAS'
   say a
   say a2
   say a2_with_commas

Mark Wheeler, 3M Company

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: rexx , formatting question

2005-06-29 Thread Perryman, Brian
n = LENGTH(a); if n>3 then do i=n-3 to 1 by -3; a=INSERT('.',a,i); end
 
Brian
 



From: IBM Mainframe Discussion List on behalf of Daniel Cremieux
Sent: Wed 29/6/05 17:05
To: IBM-MAIN@BAMA.UA.EDU
Subject: rexx , formatting question



dear gurus,

a=15.53666222

How to display only the 2 first decimal digit :

=> a=15.53 (or 15.54 i don't mind for the precision)

Thank you

another question :
a=1555666
is there any way to display it as 1.555.666 ( easier to read)


great thanks

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html
This e-mail message is for the sole use of the intended recipient(s)and may 
contain confidential and privileged information of Transaction NetworkServices. 
 
Any unauthorized review, use, disclosure or distribution isprohibited.  If you 
are not the intended recipient, please contact thesender by reply e-mail and 
destroy all copies of the original message.

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html