View previous topic :: View next topic |
Author |
Message |
John Corbin Beginner
Joined: 23 Jan 2004 Posts: 38 Topics: 21
|
Posted: Tue Jan 18, 2005 8:54 pm Post subject: formatting decimal nembers as non decimal |
|
|
I have dollar amounts of various sizes..
1234.87
2.87
32.99
as examples...
Ids there a quick way in REXX to reformat AMY dollar amount so they look like
123487
287
3299
essentially just remove te decimal point. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Jan 19, 2005 9:19 am Post subject: |
|
|
John corbin,
try this
Code: |
/* REXX */
AMTI = '2.87'
NUM1 = LEFT(AMTI,LENGTH(AMTI)-3)
NUM2 = SUBSTR(AMTI,LENGTH(AMTI)-1)
AMTO = NUM1||NUM2
SAY AMTO
|
Hope this helps...
Cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
danm Intermediate
Joined: 29 Jun 2004 Posts: 170 Topics: 73
|
Posted: Wed Jan 19, 2005 11:24 am Post subject: |
|
|
John corbin,
Try this:
Code: |
/* REXX */
Amt = 1234.87
Amt = space(translate(Amt,'','.'),0)
|
|
|
Back to top |
|
 |
John Corbin Beginner
Joined: 23 Jan 2004 Posts: 38 Topics: 21
|
Posted: Thu Jan 20, 2005 6:45 pm Post subject: |
|
|
Thanks to both of you...
both suggestions are great... actually forgot about using the Translate function. |
|
Back to top |
|
 |
s_shivaraj Beginner

Joined: 21 Sep 2004 Posts: 140 Topics: 14 Location: Chennai, India
|
Posted: Fri Jan 21, 2005 12:42 am Post subject: |
|
|
One more Simple solution,
Multiply the No by 100, remove the last 3 digits.
Example;
AMTI = '2.87'
AMTO = AMTI * 100
SAY SUBSTR(AMTO,1,LENGTH(AMTO)-3) _________________ Cheers
Sivaraj S
'Technical Skill is the Master of complexity, while Creativity is the Master of Simplicity' |
|
Back to top |
|
 |
danm Intermediate
Joined: 29 Jun 2004 Posts: 170 Topics: 73
|
Posted: Fri Jan 21, 2005 10:07 am Post subject: |
|
|
Shivaraj's solution can further simply to:
Amt = 2.87
say Amt * 100 % 1 |
|
Back to top |
|
 |
|
|