x2d, that's the one! I have to RT Friendly M every time to be sure.

Thanks.
Roops

On Thu, 3 Jul 2025, 17:03 Charles Hardee, <
0000074f21ac15f4-dmarc-requ...@listserv.ua.edu> wrote:

> Assume x=a+b+c and the result is 12345.
>
> If you want z to contain x'00003039' then...
>
> z = x2c(d2x(x,8))
>
> The inner d2x() creates a hexadecimal string of "00003039".
> The outer x2c() converts it to the "character" form of the string.
>
> And, the function to which you refer that works differently is x2d().
> If you only specify the variable field, x2d() assumes it is unsigned.
> If you add a length parm, it assumes it is signed.
>
> if x=FF, then x2d(x) gives 255, but if you use x2d(x,2), you get -1.
>
> Hope this helps.
>
> Chuck
>
> On Thu, Jul 3, 2025 at 10:53 AM Rupert Reynolds <rreyno...@cix.co.uk>
> wrote:
>
> > I tried d2c(). The c2x() is just to show what the 4 bytes in the results
> > are.
> >
> > say c2x(d2c(256,4))
> > 00000100
> >
> > I always forget which, but one of the conversion functions behaves
> > differently depending on the arguments you pass. One version is for
> > unsigned binary and the other for signed.
> >
> > n.b. Arithmetic ends up as a decimal number, stored in string
> > representation.
> >
> >
> > On Thu, 3 Jul 2025 at 16:15, Schmitt, Michael <michael.schm...@dxc.com>
> > wrote:
> >
> > > I haven't tested this, but try: right(variable, 4, '00'x)
> > >
> > > -----Original Message-----
> > > From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On
> Behalf
> > > Of Radoslaw Skorupka
> > > Sent: Thursday, July 3, 2025 10:08 AM
> > > To: IBM-MAIN@LISTSERV.UA.EDU
> > > Subject: REXX leading zeros
> > >
> > > They say there are no stupid questions...
> > >
> > >
> > > I have the following statement in REXX code (linkpgm):
> > > some_parm = '00000100'x
> > > That means 256 decimal.
> > > However I want to replace '00000100' with some variable, a result of
> > > some calculations
> > > Let's imagine, x=a+b-c
> > >
> > > How to transform x to a proper format for some_parm?
> > > Note: I have to keep the length of the variable, so '100' is not a
> > > solution.
> > >
> > > I've tried the following:
> > > x=a+b-c           /*let's say x=110+156-10 */
> > > x2=d2x(x)      /*x2 is 100, no leading zero's*/
> > > x3=RIGHT(x2,8,0)  /* now x3 is 00000100, but it is text string */
> > > x4=x2c(x3)            /* x4 consist of 4 bytes, characters are
> > > unprintable, but it is '00000100'x */
> > >
> > > It works, but isn't it reinventing the wheel? That means, am I missing
> > > some simpler way?
> > >
> > > --
> > > Radoslaw Skorupka
> > > Lodz, Poland
> > >
> > > ----------------------------------------------------------------------
> > > For IBM-MAIN subscribe / signoff / archive access instructions,
> > > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
> > >
> > >
> > >
> > > ----------------------------------------------------------------------
> > > For IBM-MAIN subscribe / signoff / archive access instructions,
> > > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
> > >
> >
> > ----------------------------------------------------------------------
> > For IBM-MAIN subscribe / signoff / archive access instructions,
> > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
> >
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to