Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

convert decimal to hex

869 views
Skip to first unread message

Joe Roden

unread,
Jul 16, 1997, 3:00:00 AM7/16/97
to

Anyone have the RPG code to convert DECIMAL to HEX.
ie: 3675594 -> 3815CA


Bradley V. Stone

unread,
Jul 23, 1997, 3:00:00 AM7/23/97
to

Bradley V. Stone
Programmer/Analyst
Taylor Corporation
bvs...@nospam.com (replace "nospam" with "taylorcorp")

Njal Fisketjon (Njål Fisketjøn)

unread,
Jul 24, 1997, 3:00:00 AM7/24/97
to

Joe Roden <jro...@uniden-nospam.com> wrote:

>Anyone have the RPG code to convert DECIMAL to HEX.
>ie: 3675594 -> 3815CA
>

Sounded like a nice little exercise, so I wrote this little program in ILE RPG
today. I think it should do what you want.


D wDec s 12 0
D wDiv s 12 0
D wHex s 16 inz('0123456789ABCDEF')
D wRes s 12 0

D xDec s 12 0
D xHex s 8

C *entry plist
C parm xDec
C parm xHex

C eval wdiv = 1
C dow wDiv < xDec
C eval wDiv = wDiv * 16
C enddo
C eval wDiv = wDiv / 16

C eval xHex = *blanks
C eval wDec = xDec

C dow wDiv > 1
C eval wRes = wDec / wDiv
C eval xHex = %trim(xHex) + %subst(wHex:wRes+1:1)
C eval wDec = wDec - (wRes * wDiv)
C eval wDiv = wDiv / 16
C enddo
C eval xHex = %trim(xHex) + %subst(wHex:wDec+1:1)

C eval *inlr = *on

Njål Fisketjøn
FIGU DATA AS
njal.fi...@figu.no
nfis...@hesgrp.com

Francesco Candia

unread,
Aug 7, 1997, 3:00:00 AM8/7/97
to

Joe Roden <jro...@uniden-nospam.com> wrote:

>Anyone have the RPG code to convert DECIMAL to HEX.
>ie: 3675594 -> 3815CA
>

DAnyDS DS
D Binary 1 4B 0
D Char 1 4

C Eval Binary = YourNum


Char is your number in Hex format
Francesco Candia
Via Monte Cervino 1/9
10090 Gassino Torinese
Italy
fca...@mbox.vol.it
francesc...@bigfoot.com

ice....@gmail.com

unread,
Feb 11, 2013, 5:46:48 AM2/11/13
to
On Thursday, 24 July 1997 08:00:00 UTC+1, Njal Fisketjon (Njål Fisketjøn) wrote:
> Joe Roden <jro...@uniden-nospam.com> wrote:
>
> >Anyone have the RPG code to convert DECIMAL to HEX.
> >ie: 3675594 -> 3815CA
> >
>
Njal,

Sixteen years after you posted this message I have found a use for it.

Many thanks for taking the trouble to put it up there all those years ago.

However, I have spotted a tiny mistake. The statement "dow wDiv < xDec" should read "dow wDiv <= xDec".

At least, I had to make this change when I converted the code to RPG400.
0 new messages