Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

converting hexadecimal into decimal

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CA Products
View previous topic :: :: View next topic  
Author Message
zulfukharali

New User


Joined: 11 May 2006
Posts: 12

PostPosted: Wed Jul 25, 2007 12:56 am    Post subject: converting hexadecimal into decimal
Reply with quote

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
Back to top
View user's profile Send private message

dick scherrer

Site Director


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

PostPosted: Wed Jul 25, 2007 1:36 am    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
zulfukharali

New User


Joined: 11 May 2006
Posts: 12

PostPosted: Wed Jul 25, 2007 1:41 am    Post subject: Re: converting hexadecimal into decimal
Reply with quote

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.
Back to top
View user's profile Send private message
Douglas Wilder

Active User


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

PostPosted: Wed Jul 25, 2007 2:52 am    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Wed Jul 25, 2007 3:10 am    Post subject:
Reply with quote

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?
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Wed Jul 25, 2007 3:23 am    Post subject:
Reply with quote

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. . . icon_redface.gif Just a thought. . .
Back to top
View user's profile Send private message
Douglas Wilder

Active User


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

PostPosted: Wed Jul 25, 2007 3:29 am    Post subject:
Reply with quote

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?
Back to top
View user's profile Send private message
Douglas Wilder

Active User


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

PostPosted: Wed Jul 25, 2007 3:33 am    Post subject:
Reply with quote

My 1989 manual from Pansophics states the the max length of a binary field is 4 bytes. Maybe this changed since 1989.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


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

PostPosted: Wed Jul 25, 2007 8:29 am    Post subject:
Reply with quote

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......
Back to top
View user's profile Send private message
Douglas Wilder

Active User


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

PostPosted: Wed Jul 25, 2007 8:39 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Wed Jul 25, 2007 9:29 pm    Post subject:
Reply with quote

Hello,

Rather than a "B" field, you might try an "I" (integer) field.
Back to top
View user's profile Send private message
Douglas Wilder

Active User


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

PostPosted: Wed Jul 25, 2007 9:36 pm    Post subject:
Reply with quote

IN-FLD5 1 4 I
*******B098 NOT A VALID TYPE - I

icon_question.gif
Back to top
View user's profile Send private message
zulfukharali

New User


Joined: 11 May 2006
Posts: 12

PostPosted: Wed Jul 25, 2007 10:32 pm    Post subject: Re: converting hexadecimal into decimal
Reply with quote

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
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CA Products All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Joinkeys with decimal scdinesh DFSORT/ICETOOL 3 Fri Feb 10, 2017 4:46 am
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
This topic is locked: you cannot edit posts or make replies. DB2 query Using Recursion, Converting... smilewithashu2 DB2 3 Tue Jan 03, 2017 12:50 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us