View previous topic :: View next topic |
Author |
Message |
yadav2005 Intermediate
Joined: 10 Jan 2005 Posts: 348 Topics: 144
|
Posted: Thu Nov 15, 2007 4:00 pm Post subject: how to interpret binary values |
|
|
Members,
I have a dataset when see in browse mode:
Code: |
----+
.. ..
.. ..
.. ..
.. ..
|
When i put Hex on
Code: |
.. ..
00400
01001
-----
.. ..
004FF
020FF
|
I am reading this file into a program , i want to insert / override equivalent of binary 2 to be inserted in cols 4 - 5 for the first record ,basically it is a binary data PIC S9(04) COMP which takes 2 bytes , can somebody help me ? Also how can i interpret the Binary values stored in 2 bytes in pos 4 -5 to what exactly is the value ? |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Nov 15, 2007 4:41 pm Post subject: |
|
|
yadav2005,
You can use the following DFSORT job to view the contents of the binary values.
If you have both negative/positive values then use FI format and if you are sure that you only have positive values then use BI format
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=YOUR BINARY INPUT FILE,
// DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(p,m,FI,M26)
//*
//* p = position of the binary field in the file
//* m = length of the binary filed
//* m26 = pre-defined edit mask explained in the below link
|
DFSORT Edit Masks
Hope this helps... _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
mf_user Intermediate
Joined: 01 Jun 2003 Posts: 372 Topics: 105
|
Posted: Fri Oct 17, 2008 6:46 am Post subject: My Question on M26 Mask |
|
|
Hi,
I supplied below low-values in SYSIN and got the below displayed in SYSOUT !
Sysin:
Code: |
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1,6,FI,M26)
|
But, when I check each byte individually it is shown differently.....
For 00 - +000
For 01 - +001
For 02 - +002
For FF - +255
For 20 - +032 etc
Would you please explain.
Thanks. _________________ MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
== |
|
Back to top |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Fri Oct 17, 2008 9:52 am Post subject: |
|
|
MF,
I guess you are making a basic mistake by looking at each byte seperately and not as a whole. Remember a decimal number '123' is not 1, 2, 3 but 100+20+3.
Similarly a hexadecimal number, '0102ff20ff' is ff + (20*16) + ff*(16**2) + ff*(16**3) + 2*(16**4) + 1*(16**5), bracketed operations are in decimal. Not 01, 02, ff, 20, ff
To clarify further you can try open a calculator in scientifc mode. Put '0102ff20ff' as hex number. Then select decimal to see the transformation.
Diba. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
|
Back to top |
|
|
mf_user Intermediate
Joined: 01 Jun 2003 Posts: 372 Topics: 105
|
Posted: Fri Oct 17, 2008 11:48 am Post subject: |
|
|
Dibakar, using CALC in PC is better idea. Thanks. _________________ MF
==
Any training that does not include the emotions, mind and body is incomplete; knowledge fades without feeling.
== |
|
Back to top |
|
|
Frank Yaeger Sort Forum Moderator
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Fri Oct 17, 2008 12:06 pm Post subject: |
|
|
Quote: | '0102ff20ff' is ff + (20*16) + ff*(16**2) + ff*(16**3) + 2*(16**4) + 1*(16**5) |
You have it wrong. It would be the following in decimal:
(15*16**0)+(15*16**1)+(0*16**2)+(2*16**3)+(15*16**4)+(15*16**5)+(2*16**6)+(0*16**7)+(1*16**8) _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|
Back to top |
|
|
Dibakar Advanced
Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Tue Nov 11, 2008 9:58 pm Post subject: |
|
|
Opps, I missed this post and the correction. Thanks Frank. |
|
Back to top |
|
|
|
|