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 <[email protected]> wrote: > I haven't tested this, but try: right(variable, 4, '00'x) > > -----Original Message----- > From: IBM Mainframe Discussion List <[email protected]> On Behalf > Of Radoslaw Skorupka > Sent: Thursday, July 3, 2025 10:08 AM > To: [email protected] > 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 [email protected] with the message: INFO IBM-MAIN > > > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to [email protected] with the message: INFO IBM-MAIN > ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
