View previous topic :: View next topic
|
Author |
Message |
zulfukharali
New User
Joined: 11 May 2006 Posts: 12
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
zulfukharali
New User
Joined: 11 May 2006 Posts: 12
|
|
|
|
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 |
|
|
Douglas Wilder
Active User
Joined: 28 Nov 2006 Posts: 305 Location: Deerfield IL
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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. . . |
|
Back to top |
|
|
Douglas Wilder
Active User
Joined: 28 Nov 2006 Posts: 305 Location: Deerfield IL
|
|
|
|
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 |
|
|
Douglas Wilder
Active User
Joined: 28 Nov 2006 Posts: 305 Location: Deerfield IL
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
Douglas Wilder
Active User
Joined: 28 Nov 2006 Posts: 305 Location: Deerfield IL
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Rather than a "B" field, you might try an "I" (integer) field. |
|
Back to top |
|
|
Douglas Wilder
Active User
Joined: 28 Nov 2006 Posts: 305 Location: Deerfield IL
|
|
|
|
IN-FLD5 1 4 I
*******B098 NOT A VALID TYPE - I
|
|
Back to top |
|
|
zulfukharali
New User
Joined: 11 May 2006 Posts: 12
|
|
|
|
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 |
|
|
|