<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Physical Representation of Binary Data in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109058#M38902</link>
    <description>You are probably just confused with little endian vs big endian&lt;BR /&gt;&lt;BR /&gt;( &lt;A href="http://en.wikipedia.org/wiki/Endianness" target="_blank"&gt;http://en.wikipedia.org/wiki/Endianness&lt;/A&gt; )&lt;BR /&gt;&lt;BR /&gt;Handy documenation for the OpenVMS data types can be found (amongst other places) in the MACRO language manual:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://h71000.www7.hp.com/doc/73final/4515/4515pro_012.html#basic_architecture" target="_blank"&gt;http://h71000.www7.hp.com/doc/73final/4515/4515pro_012.html#basic_architecture&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I don't need to tell you that Cobol, while a find language in general, is not very suited for bit manipulation no?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;For a convienent, albiet not max speed, method to didle with bit-vield you may want to check out the functions LIB$EXTV and LIB$INSV:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://h71000.www7.hp.com/DOC/82final/5932/5932pro_016.html" target="_blank"&gt;http://h71000.www7.hp.com/DOC/82final/5932/5932pro_016.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;and&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://h71000.www7.hp.com/doc/82final/5932/5932pro_032.html" target="_blank"&gt;http://h71000.www7.hp.com/doc/82final/5932/5932pro_032.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;But you can also do an AND and stuff on comps.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Good luck!&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
    <pubDate>Wed, 28 Nov 2007 14:34:51 GMT</pubDate>
    <dc:creator>Hein van den Heuvel</dc:creator>
    <dc:date>2007-11-28T14:34:51Z</dc:date>
    <item>
      <title>Physical Representation of Binary Data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109057#M38901</link>
      <description>I'm working in COBOL and want to manipulate data at the bit level by redefining an alphanumeric field as a numeric COMP field.  To do this I need to understand how positive and negative integers are stored in binary fields. The reference and user manuals simply describe the format as "Word integer".&lt;BR /&gt;&lt;BR /&gt;What is the physical representation of these word integers?  What would be the hexadecimal result of placing -1234 in an S9(4) COMP field? (It doesn't seem to be "FB2E" which is what I expected).&lt;BR /&gt;&lt;BR /&gt;Many thanks for any help on this.</description>
      <pubDate>Wed, 28 Nov 2007 12:49:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109057#M38901</guid>
      <dc:creator>Dave Overall</dc:creator>
      <dc:date>2007-11-28T12:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Physical Representation of Binary Data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109058#M38902</link>
      <description>You are probably just confused with little endian vs big endian&lt;BR /&gt;&lt;BR /&gt;( &lt;A href="http://en.wikipedia.org/wiki/Endianness" target="_blank"&gt;http://en.wikipedia.org/wiki/Endianness&lt;/A&gt; )&lt;BR /&gt;&lt;BR /&gt;Handy documenation for the OpenVMS data types can be found (amongst other places) in the MACRO language manual:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://h71000.www7.hp.com/doc/73final/4515/4515pro_012.html#basic_architecture" target="_blank"&gt;http://h71000.www7.hp.com/doc/73final/4515/4515pro_012.html#basic_architecture&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I don't need to tell you that Cobol, while a find language in general, is not very suited for bit manipulation no?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;For a convienent, albiet not max speed, method to didle with bit-vield you may want to check out the functions LIB$EXTV and LIB$INSV:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://h71000.www7.hp.com/DOC/82final/5932/5932pro_016.html" target="_blank"&gt;http://h71000.www7.hp.com/DOC/82final/5932/5932pro_016.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;and&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://h71000.www7.hp.com/doc/82final/5932/5932pro_032.html" target="_blank"&gt;http://h71000.www7.hp.com/doc/82final/5932/5932pro_032.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;But you can also do an AND and stuff on comps.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Good luck!&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Nov 2007 14:34:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109058#M38902</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-11-28T14:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: Physical Representation of Binary Data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109059#M38903</link>
      <description>Dave,&lt;BR /&gt;&lt;BR /&gt;I agree with Hein, the most likely source of confusion has to do with little-endian vs big-endian byte ordering.&lt;BR /&gt;&lt;BR /&gt;In a little endian representation (used on all OpenVMS platforms), the lowest order bit is at the lowest address. Thus, in the example of -1234 (0xFB2E), the lowest order byte (0x2E) will be at the lowest address. In a big-endian representation, largest byte is at the lowest address. &lt;BR /&gt;&lt;BR /&gt;I do not have the citation, but there was a nice article a long time ago about this difference in either IEEE Spectrum or IEEE Computer.&lt;BR /&gt;&lt;BR /&gt;Most architectures that are currently extant use two's complement arithmetic. In thhis scheme, the negative numbers are padded with high order "1" bits, the positive numbers are padded with high order "0" bits.  &lt;BR /&gt;&lt;BR /&gt;One of the architecture handbooks is good for a discussion of two's complement arithmetic, as are any of the college-level texts on computer hardware design.&lt;BR /&gt;&lt;BR /&gt;What "unexpected" results are you seeing?&lt;BR /&gt;&lt;BR /&gt;- Bob Gezelter, &lt;A href="http://www.rlgsc.com" target="_blank"&gt;http://www.rlgsc.com&lt;/A&gt;</description>
      <pubDate>Wed, 28 Nov 2007 15:00:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109059#M38903</guid>
      <dc:creator>Robert Gezelter</dc:creator>
      <dc:date>2007-11-28T15:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Physical Representation of Binary Data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109060#M38904</link>
      <description>btw... if you defined onto a pic9(4) only because 'that is big enough', then please don't.&lt;BR /&gt;&lt;BR /&gt;Please used pic 9(9) comp or pic s9(9) comp everywhere you can and make them aligned by using a 01, or a carefully arranged lower level field.&lt;BR /&gt;&lt;BR /&gt;To convince yourself as to why, please take the 5 or 10 minutes to study the output from COBOL/LIST/MACHINE for a short program.&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Nov 2007 15:16:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109060#M38904</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-11-28T15:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: Physical Representation of Binary Data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109061#M38905</link>
      <description>Dave,&lt;BR /&gt;  What do you need to do at the bit level? There may be easier (and faster) ways.&lt;BR /&gt;&lt;BR /&gt;  As Hein suggested, COBOL is great at what COBOL does, but low level bit manipulation isn't one of them.&lt;BR /&gt;&lt;BR /&gt;  With such a rich range of data types, it's also sometimes difficult to determine exactly what representation COBOL will use. There's a large table in an appendix in the Cobol Reference Manual which maps COBOL PIC clauses to lower level data types. You may also need to refer to the Architecture Reference Manual for your architecture to work out the binary representation for the data types.&lt;BR /&gt;</description>
      <pubDate>Wed, 28 Nov 2007 17:29:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109061#M38905</guid>
      <dc:creator>John Gillings</dc:creator>
      <dc:date>2007-11-28T17:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Physical Representation of Binary Data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109062#M38906</link>
      <description>I would write a simple program with a selection of data types, and then run it with /debug&lt;BR /&gt;You can then deposit -1234 and then examine the data item, it will be FB2E&lt;BR /&gt;you can even examine/hex or examine/binary to be sure to be sure.&lt;BR /&gt;you could also define the item as usage binary, but I don't know if this would be of any benefit.&lt;BR /&gt;Phil</description>
      <pubDate>Wed, 28 Nov 2007 22:47:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109062#M38906</guid>
      <dc:creator>Phil.Howell</dc:creator>
      <dc:date>2007-11-28T22:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: Physical Representation of Binary Data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109063#M38907</link>
      <description>To Hein, Robert, John and Phil,&lt;BR /&gt;&lt;BR /&gt;Thanks very much for all your responses. It's been a very useful learning experience but after running into parity bit problems I've decided to do this another way.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Dave&lt;BR /&gt;</description>
      <pubDate>Thu, 29 Nov 2007 10:59:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109063#M38907</guid>
      <dc:creator>Dave Overall</dc:creator>
      <dc:date>2007-11-29T10:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Physical Representation of Binary Data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109064#M38908</link>
      <description>Parity bit?  What parity bit?&lt;BR /&gt;&lt;BR /&gt;Are you working with a serial line, or some sort of external hardware?&lt;BR /&gt;&lt;BR /&gt;Neither VAX, Alpha nor Itanium memory will have any sort of (application-visible) parity bit.&lt;BR /&gt;&lt;BR /&gt;There's certainly a sign bit that can come into play, depending on how the integer value is declared and processed.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 29 Nov 2007 14:00:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109064#M38908</guid>
      <dc:creator>Hoff</dc:creator>
      <dc:date>2007-11-29T14:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Physical Representation of Binary Data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109065#M38909</link>
      <description>Hello Hoff,&lt;BR /&gt;&lt;BR /&gt;I tried to follow-up on each of the suggestions above but I still don't seem to be able to match the results I'm getting with the results I think I should get. Let me try and provide a more complete description of what I'm trying to do.&lt;BR /&gt;&lt;BR /&gt;I need to quantify the difference between one 32 byte alphanumeric string (A) and another (B).  I redefine both 01 level strings with PIC S9(4) COMP OCCURS 16 and subtract each binary field in string (A) from each binary field in string (B), checking for a non-zero result.&lt;BR /&gt;&lt;BR /&gt;When the two byte positions are exactly the same, I get zero - as expected. However, in my test case, I have string (A) which contains "RS" in positions 10 &amp;amp; 11 and string (B) which contains "RT" in positions 10 &amp;amp; 11.  Originally, I expected a difference of 1 but after reading about little endian binary storage, I realised that VMS will view these strings as "SR" and "TR" in terms of their numerical significance.&lt;BR /&gt;&lt;BR /&gt;According to my ASCII tables "SR" should convert to hex "5352" and "TR" to hex "5452". This should give me the result of hex "0100" or decimal 256. Even if I do the maths in binary: 01010100,01010010 - 01010011,01010010 = 100000000 which is still decimal 256.&lt;BR /&gt;&lt;BR /&gt;The problem is that in my test results, I get decimal 265 as a result of this subtraction.&lt;BR /&gt;&lt;BR /&gt;Then I thought of ASCII parity bits. I tried the subtraction using even parity and got some very large nagative numbers. I presumed that these were being truncated at various stages in the calculation and that this must be the explanation for my results - although I've not been able to work out exactly what was going on.&lt;BR /&gt;&lt;BR /&gt;If you're saying that parity bits wouldn't be included in my text strings, I'm even more confused than before.&lt;BR /&gt;&lt;BR /&gt;I probably just shouldn't try to do bit manipulation using COBOL but I feel I should be able to understand what's being stored in these fields.&lt;BR /&gt;&lt;BR /&gt;Dave&lt;BR /&gt;</description>
      <pubDate>Tue, 04 Dec 2007 09:00:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109065#M38909</guid>
      <dc:creator>Dave Overall</dc:creator>
      <dc:date>2007-12-04T09:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Physical Representation of Binary Data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109066#M38910</link>
      <description>Sorry!&lt;BR /&gt;&lt;BR /&gt;The "RT"/"RS" are in positions 9 &amp;amp; 10 - not 10 &amp;amp; 11 as previously stated.&lt;BR /&gt;&lt;BR /&gt;Dave</description>
      <pubDate>Tue, 04 Dec 2007 09:04:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109066#M38910</guid>
      <dc:creator>Dave Overall</dc:creator>
      <dc:date>2007-12-04T09:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: Physical Representation of Binary Data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109067#M38911</link>
      <description>Dave,&lt;BR /&gt;&lt;BR /&gt;  With little endian representation, ASCII strings are read "backwards". The first character in the string is the least significant byte (lowest address). You probably have to play with the DUMP command to see how it works. Simple example:&lt;BR /&gt;&lt;BR /&gt;$ create ascii.txt&lt;BR /&gt;here is some ASCII text^Z&lt;BR /&gt;&lt;BR /&gt;$ dump/record ascii.txt&lt;BR /&gt;&lt;BR /&gt;Dump of file DKA100:[JG]ASCII.TXT;1 on  5-DEC-2007 09:05:20.57&lt;BR /&gt;File ID (105,3941,0)   End of file block 1 / Allocated 141&lt;BR /&gt;&lt;BR /&gt;Record number 1 (00000001), 23 (0017) bytes, RFA(0001,0000,0000)&lt;BR /&gt;&lt;BR /&gt; 43534120 656D6F73 20736920 65726568 here is some ASC 000000&lt;BR /&gt;                     747865 74204949 II text......... 000010&lt;BR /&gt;&lt;BR /&gt;With a dump you read the text part on the right from left to right, but the binary part on the left from right to left. (sounds a bit silly when expressed like that, but that's how it works, and when you get used to it is makes sense).&lt;BR /&gt;&lt;BR /&gt;So, the text "here" translates to the right most 32 bit integer, "65726568" which you need to read right to left. The LEAST significant byte when interpreted as a numeric value is "h". So, if you have 4 byte strings, which you want to interpret as INTEGER and sort in the same sequence as the ASCII text, you need to shuffle the bytes around. Swap bytes 0 and 3 and swap bytes 1 and 2. So "here" would transform into "68657265" which would then read as ASCII "ereh". &lt;BR /&gt;&lt;BR /&gt;Does this clear up anything?</description>
      <pubDate>Tue, 04 Dec 2007 22:06:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109067#M38911</guid>
      <dc:creator>John Gillings</dc:creator>
      <dc:date>2007-12-04T22:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Physical Representation of Binary Data</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109068#M38912</link>
      <description>&lt;!--!*#--&gt;Sorry, format of the dump messed up. Hopefully this will look better:&lt;BR /&gt;&lt;BR /&gt;$ dump/record ascii.txt&lt;BR /&gt;&lt;BR /&gt;Dump of file DKA100:[JG]ASCII.TXT;1 on  5-DEC-2007 09:05:20.57&lt;BR /&gt;File ID (105,3941,0)   End of file block 1 / Allocated 141&lt;BR /&gt;&lt;BR /&gt;Record number 1 (00000001), 23 (0017) bytes, RFA(0001,0000,0000)&lt;BR /&gt;&lt;BR /&gt; 43534120 656D6F73 20736920 65726568 here is some ASC 000000&lt;BR /&gt;                     747865 74204949 II text......... 000010&lt;BR /&gt;</description>
      <pubDate>Tue, 04 Dec 2007 22:08:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/physical-representation-of-binary-data/m-p/4109068#M38912</guid>
      <dc:creator>John Gillings</dc:creator>
      <dc:date>2007-12-04T22:08:01Z</dc:date>
    </item>
  </channel>
</rss>

