Convert one byte Hex to numeric
Convert one byte Hex to numeric
(OP)
Hello,
I hate to admit this but I am struggling a bit here.
I am working with a file that contains a one byte field in binary (i.e. hex) that I need to convert to numeric. To be more specific I have an example; the one byte field in hex comes in as an '80', which in turn should translate to '128'. But I haven't been able to accomplish this ... I know there is a way but can't seem to figure this out.
Ex.
ᴓ

8
0
I need to develop a way to take this one byte '80' and convert it to the numeric equivalent of 128. I am using '80' but it could be any value that that one byte could contain.
If anyone could help; I would be eternally grateful.
Regards
I hate to admit this but I am struggling a bit here.
I am working with a file that contains a one byte field in binary (i.e. hex) that I need to convert to numeric. To be more specific I have an example; the one byte field in hex comes in as an '80', which in turn should translate to '128'. But I haven't been able to accomplish this ... I know there is a way but can't seem to figure this out.
Ex.
ᴓ

8
0
I need to develop a way to take this one byte '80' and convert it to the numeric equivalent of 128. I am using '80' but it could be any value that that one byte could contain.
If anyone could help; I would be eternally grateful.
Regards
RE: Convert one byte Hex to numeric
Hope This Helps, PH.
FAQ2192884: How Do I Get Great Answers To my TekTips Questions?
FAQ1812886: How can I maximize my chances of getting an answer?
RE: Convert one byte Hex to numeric
So you have to redefine things, to get where you're wanting to go. Something like (untested b/c no compiler where I'm at now):
CODE
01 Filterdata.
04 FILTERNUM pic S9(4) Binary.
04 filtertext redefines filternum.
08 filler pic x value lowvalues.
08 lastnum pic x.
01 outputnumber pic zzz9.
MOVE INPUTHEX to LASTNUM.
move filternum to outputnumber.
display outputnumber.
Hope that helps at least get you into the ballpark for a solution.
I'm waiting for the white paper entitled "Finding Employment in the Era of Occupational Irrelevancy"
RE: Convert one byte Hex to numeric
With Micro Focus COBOL, the COMP directive must be turned on to use 1byte binary fields. I'm not sure what the default is.
RE: Convert one byte Hex to numeric
I'm waiting for the white paper entitled "Finding Employment in the Era of Occupational Irrelevancy"
RE: Convert one byte Hex to numeric
The code works like a champ .... I am very grateful.
If you're close by in Wilmington Delaware .... drinks on me the whole night.
Thanks a ton ... man ... much appreciated.
Now I am going to study the solution so that I can clearly understand.
Frank
RE: Convert one byte Hex to numeric