Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
zulfukharali

New User

Joined: 11 May 2006
Posts: 12

 Posted: Wed Jul 25, 2007 12:56 am    Post subject: converting hexadecimal into decimal Hi, In EZT, when I convert the 4 bytes hexadecimal value into 10 digit numeric I could able to make it for smaller values. For example X' EC69F5DC' is not giving the correct numeric value. It should be 3966367196 instead I am getting 0328600100. In REXX, I could able to make it by making NUMERIC DIGITS 10 command. Is there any command or any steps to follow to convert the 4 bytes hexadecimal into 10 digit numeric value. Please let me know how to interpret the 4 bytes of hexadecimal data into decimal. Thanks in advance ZA

dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

 Posted: Wed Jul 25, 2007 1:36 am    Post subject: Hello, If you post your ezt code we may be able to offer suggestions. Post the variable definition and the instructions. Hopefully, you have a small test program for this working out rather than having it buried in a lot of other code.
zulfukharali

New User

Joined: 11 May 2006
Posts: 12

 Posted: Wed Jul 25, 2007 1:41 am    Post subject: Re: converting hexadecimal into decimal FILE INFILE IN-RECORD 1 2004 A IN-TYPE 3 2 B IN-WRK-BAL 55 7 P IN-TRAN 97 2 B IN-CO-ID 99 2 B IN-APPL-ID 109 2 B IN-SEQ 111 4 B IN-FUNC-ID 126 2 B IN-ACCT-NO 101 8 P IN-DATE 90 4 P FILE OUTFILE OUT-RECORD 1 80 A OUT-TYPE 1 2 N OUT-TRAN 4 4 N OUT-CO-ID 9 5 N OUT-APPL-ID 15 4 N OUT-SEQ 20 10 N OUT-FUNC-ID 31 4 N OUT-ACCT-NO 36 15 N OUT-DATE 52 7 N OUT-WRK-BAL 60 14 N * JOB INPUT(INFILE) OUT-TYPE = IN-TYPE OUT-TRAN = IN-TRAN OUT-CO-ID = IN-CO-ID OUT-APPL-ID = IN-APPL-ID OUT-SEQ = IN-SEQ OUT-FUNC-ID = IN-FUNC-ID OUT-ACCT-NO = IN-ACCT-NO OUT-DATE = IN-DATE OUT-WRK-BAL = IN-WRK-BAL PUT OUTFILE The IN-SEQ-NO is the hexadecimal value in the file and decalared as binary. it is working fine for low value data (if it fits with in 9 digits). It is not working once it exceeds 9 digits. Example: If IN-SEQ x'EC69F5DC' is OUT-SEQ =0328600100 rather OUT-SEQ should be 3966367196. Please advice.
Douglas Wilder

Active User

Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

 Posted: Wed Jul 25, 2007 2:52 am    Post subject: It appears to have something to do with the left bit of the binary number being used as a sign bit. If you want it to be treated as an unsigned binary number you could break it into 2 2 byte binary fields as follows: IN-SEQ1 111 2 B IN-SEQ2 113 2 B . . . . OUT-SEQ 20 10 N . . . . TEMP1 W 10 N TEMP2 W 10 N . . . . TEMP1 = IN-SEQ1 TEMP2 = IN-SEQ2 OUT-SEQ = TEMP1 * 65536 + TEMP2 I hope this is of help.
William Thompson

Global Moderator

Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

 Posted: Wed Jul 25, 2007 3:10 am    Post subject: Good call, but won't the high two bytes still retain the sign? Wouldn't it need a character move to a portion of an area redefined into the low end of a four byte binary?
dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

 Posted: Wed Jul 25, 2007 3:23 am    Post subject: Hello, You might try creating an 8-byte binary number where the first 4 bytes are x'00000000' and the second 4 bytes are your 4-byte hex value. This way your high order bit would always be positive. When that value was moved to out-seq, you wouldn't get the "negative" value. I've not tried this and am not sure that ezt supports the 8-byte binary. . . Just a thought. . .
Douglas Wilder

Active User

Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

 Posted: Wed Jul 25, 2007 3:29 am    Post subject: If he want the results he asked for this will work. Apparently the 2 byte binary numbers are treated as unsigned. I tested this and got the result he requested. If the binary number should be treated as signed some other solution would be needed. We must ask, where did this binary number come from and how does that treat these numbers?
Douglas Wilder

Active User

Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

 Posted: Wed Jul 25, 2007 3:33 am    Post subject: My 1989 manual from Pansophics states the the max length of a binary field is 4 bytes. Maybe this changed since 1989.
William Thompson

Global Moderator

Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

Posted: Wed Jul 25, 2007 8:29 am    Post subject:

 Douglas Wilder wrote: If he want the results he asked for this will work. Apparently the 2 byte binary numbers are treated as unsigned. I tested this and got the result he requested.
Did you test it with numbers in the range of 2,147,483,648 to 4,294,967,295?
 Quote: If the binary number should be treated as signed some other solution would be needed.
If it should be treated as signed, he wouldn't be having this problem....
 Quote: We must ask, where did this binary number come from and how does that treat these numbers?
Unsigned binary is available from many sources.

My 2000 manual from CA agrees......
Douglas Wilder

Active User

Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

 Posted: Wed Jul 25, 2007 8:39 pm    Post subject: I tested it changing the left nibble from zero through F ie X' 0C69F5DC' through X' FC69F5DC' and got the following results: 0208270812, 0476706268, 0745141724, 1013577180, 1282012636 1550448092, 1818883548, 2087319004, 2355754460, 2624189916 2892625372, 3161060828, 3429496284, 3697931740, 3966367196 4234802652 For case he sighted X' EC69F5DC' it gave the result of 3966367196 as he requested. If it should have been treated as signed he should have gotten negative numbers and he did not get them. Yes, "Unsigned binary is available from many sources". The question is, did this come from one of them.
dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

 Posted: Wed Jul 25, 2007 9:29 pm    Post subject: Hello, Rather than a "B" field, you might try an "I" (integer) field.
Douglas Wilder

Active User

Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

 Posted: Wed Jul 25, 2007 9:36 pm    Post subject: IN-FLD5 1 4 I *******B098 NOT A VALID TYPE - I
zulfukharali

New User

Joined: 11 May 2006
Posts: 12

 Posted: Wed Jul 25, 2007 10:32 pm    Post subject: Re: converting hexadecimal into decimal Thanks to all and dick. I tried your solution on COBOL (declaring as 8 byte) 05 WS-SEQ-B PIC 9(18) USAGE BINARY 05 WS-SEQ REDEFINES WS-SEQ-B. 10 WS-SEQ-1 PIC X(4). 10 WS-SEQ-2 PIC X(4). and moving it to output field as MOVE IN-SEQ TO WS-SEQ-2 MOVE WS-SEQ-B TO SEQ-NBR It worked out. I convinced my parties to write the code in COBOL than EZT. But I haven't tried in EZT. I will do that later. Once again Thanks to all and special thanks to dick. Thanks SZA
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics How can I convert charactor to fixed ... liying DFSORT/ICETOOL 7 Tue May 22, 2018 3:35 pm converting a mainframe file with ASA ... Lynne Schuler All Other Mainframe Topics 5 Wed Apr 04, 2018 9:44 am How to group and sum the decimal value sakrat DFSORT/ICETOOL 2 Tue Mar 06, 2018 9:13 pm Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us