Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rexx p2d an d d2p functions

Status
Not open for further replies.

tbrownch

IS-IT--Management
Aug 6, 2007
2
US
have seen references to these 2 functions but they dont
seem to be part of rexx that run on z/os 1.7

 

They're home-grown. They are not a part of the product.

Frank Clarke
Tampa Area REXX Programmers' Alliance
REXX Language Assn Listmaster
 
If you are looking for a p2d and d2p function,
try these.

/* REXX */
trace off
Nop
B = '123B'x
C = '123C'x
D = '123D'x
F = '123F'x
say 'B='p2d(B) 'C='p2d(C) 'D='p2d(D) 'F='p2d(F)

B = - 27.345
C = 127.345
D = -127.345
F = +27.345
Bp = d2p(B)
Cp = d2p(C)
Dp = d2p(D)
Fp = d2p(F)
say 'B='p2d(Bp) 'C='p2d(Cp) 'D='p2d(Dp) 'F='p2d(Fp)
exit

/* packed to decimal */
p2d: procedure
arg pd
Return (translate(right(C2X(pd),1),'-- ','BDACEF')||,
left(C2X(pd),length(C2X(pd))-1)) + 0

/* decimal to packed */
d2p: procedure
arg dec
If dec < 0 then s = 'D'; else s = 'C'
n = space(translate(dec,,'+-.')s,0)
Return X2C(right(n,length(n)+length(n)//2,'0'))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top