<?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: How do I perform bitwise xor operations between columns with 44-bit binary data? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-perform-bitwise-xor-operations-between-columns-with-44/m-p/559282#M77276</link>
    <description>&lt;P&gt;Here is one way to handle the problem&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1666406596889.png" style="width: 714px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/46503i1CB3D552679031CC/image-dimensions/714x250?v=v2" width="714" height="250" role="button" title="txnelson_0-1666406596889.png" alt="txnelson_0-1666406596889.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( i = 1, i &amp;lt;= 1, i = i + 15,
	loops = Ceiling( Length( :A ) / 15 );
	val = "";
	For( i = 1, i &amp;lt;= Length( :A ), i = i + 15,
		Asub = Substr( :A, i, 15 );
		absLength = Length( Asub );
		zeros = Repeat( "0", absLength );
		Bsub = Substr( :B, i, 15 );
		Csub = Sum( Num( Asub ), Num( Bsub ) );
		Csub = Format( Csub, "Fixed Dec", 15, 0 );
		If( Length( Csub ) != absLength,
			Csub = Substr( zeros, 1, absLength - Length( Csub ) ) || Csub
		);
		val = val || Csub;
	);
	val = Substitute( val, "2", "0" );
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 22 Oct 2022 02:45:11 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2022-10-22T02:45:11Z</dc:date>
    <item>
      <title>How do I perform bitwise xor operations between columns with 44-bit binary data?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-perform-bitwise-xor-operations-between-columns-with-44/m-p/559280#M77275</link>
      <description>I want to perform bitwise xor operations between two columns and output the result in the 3rd column. Please note that the values are 44 bits long in both columns.&lt;BR /&gt;&lt;BR /&gt;Please assume as an example the values are 1s on one column and 0s on the other, 44 bits long. Can you explain how I can achieve this with a formula or a jsl script?</description>
      <pubDate>Sat, 10 Jun 2023 23:55:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-perform-bitwise-xor-operations-between-columns-with-44/m-p/559280#M77275</guid>
      <dc:creator>psundar6</dc:creator>
      <dc:date>2023-06-10T23:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I perform bitwise xor operations between columns with 44-bit binary data?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-perform-bitwise-xor-operations-between-columns-with-44/m-p/559282#M77276</link>
      <description>&lt;P&gt;Here is one way to handle the problem&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1666406596889.png" style="width: 714px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/46503i1CB3D552679031CC/image-dimensions/714x250?v=v2" width="714" height="250" role="button" title="txnelson_0-1666406596889.png" alt="txnelson_0-1666406596889.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( i = 1, i &amp;lt;= 1, i = i + 15,
	loops = Ceiling( Length( :A ) / 15 );
	val = "";
	For( i = 1, i &amp;lt;= Length( :A ), i = i + 15,
		Asub = Substr( :A, i, 15 );
		absLength = Length( Asub );
		zeros = Repeat( "0", absLength );
		Bsub = Substr( :B, i, 15 );
		Csub = Sum( Num( Asub ), Num( Bsub ) );
		Csub = Format( Csub, "Fixed Dec", 15, 0 );
		If( Length( Csub ) != absLength,
			Csub = Substr( zeros, 1, absLength - Length( Csub ) ) || Csub
		);
		val = val || Csub;
	);
	val = Substitute( val, "2", "0" );
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Oct 2022 02:45:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-perform-bitwise-xor-operations-between-columns-with-44/m-p/559282#M77276</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-10-22T02:45:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I perform bitwise xor operations between columns with 44-bit binary data?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-perform-bitwise-xor-operations-between-columns-with-44/m-p/559288#M77279</link>
      <description>&lt;P&gt;Extending Jim's approach of using add for XOR, and using some matrix functions to remove the loops...and an ASCII table.&lt;/P&gt;
&lt;P&gt;These are untested, make sure they do what you expect.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;char_xor = Function( {a, b}, {aa, bb}, 
    aa = Blob To Matrix( Char To Blob( a ), "int", 1, "little" ); // string to matrix...
    bb = Blob To Matrix( Char To Blob( b ), "int", 1, "little" ); // "0" -&amp;gt; 48, "1" -&amp;gt; 49
    cc = Mod( aa + bb, 2 ); // XOR, 48+48-&amp;gt;0, 48+49-&amp;gt;1, 49+49-&amp;gt;0
    Blob To Char( Matrix To Blob( cc + 48, "int", 1, "little" ) ); // 0-&amp;gt;48, 1-&amp;gt;49
);
char_or = Function( {a, b}, {aa, bb}, 
    aa = Blob To Matrix( Char To Blob( a ), "int", 1, "little" ); // string to matrix...
    bb = Blob To Matrix( Char To Blob( b ), "int", 1, "little" ); // "0" -&amp;gt; 48, "1" -&amp;gt; 49
    cc = aa + bb != 96; // OR, 96 is "0"+"0" == 48+48
    Blob To Char( Matrix To Blob( cc + 48, "int", 1, "little" ) ); // 0-&amp;gt;48, 1-&amp;gt;49
);
char_and = Function( {a, b}, {aa, bb}, 
    aa = Blob To Matrix( Char To Blob( a ), "int", 1, "little" ); // string to matrix...
    bb = Blob To Matrix( Char To Blob( b ), "int", 1, "little" ); // "0" -&amp;gt; 48, "1" -&amp;gt; 49
    cc = Mod( aa, 2 ) :*&lt;/img&gt; Mod( bb, 2 ); // AND, :*&lt;/img&gt; is element-wise. multiply 0*0, 1*0, 0*1, 1*1
    Blob To Char( Matrix To Blob( cc + 48, "int", 1, "little" ) ); // 0-&amp;gt;48, 1-&amp;gt;49
);
char_not = Function( {a},
    Substitute( a, "0", "*", "1", "0", "*", "1" ); // NOT
);

// tests

Show( char_xor( "0011", "0101" ) == "0110",
      char_or( "0011", "0101" ) == "0111",
      char_and( "0011", "0101" ) == "0001",
      char_not( "01" ) == "10" );

p = "00110000011111";
q = "01010101011100";

Show( p, q, char_not( char_and( p, q ) ) == char_or( char_not( p ), char_not( q ) ) ); // De Morgan's Theorem
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You might want error checks for bad characters like "010130101".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wow. Substitute did not work the way I thought it would.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Oct 2022 04:41:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-perform-bitwise-xor-operations-between-columns-with-44/m-p/559288#M77279</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2022-10-22T04:41:38Z</dc:date>
    </item>
  </channel>
</rss>

