<?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: 2's complement in LabWindows/CVI</title>
    <link>https://ni.lithium.com/t5/LabWindows-CVI/2-s-complement/m-p/280370#M19084</link>
    <description>&lt;DIV&gt;&lt;/DIV&gt;Hello,&lt;BR /&gt;
&lt;BR /&gt;Signed integers are already represented using two's complement, so
if you are only concerned with 16-bit integers (like 0xFFFF and
0x8000), all you have to do is cast the value as a &lt;FONT face="Courier New"&gt;short int.&lt;FONT face="Arial"&gt; If you need to interpret other sizes, the general method would be this:&lt;BR /&gt;
&lt;BR /&gt;
&lt;FONT face="Courier New"&gt;int highBitMask = 1 &amp;lt;&amp;lt; (numBits - 1);&lt;BR /&gt;
&lt;BR /&gt;
(~highBitMask &amp;amp; number) - (highBitMask &amp;amp; number);&lt;BR /&gt;
&lt;BR /&gt;
&lt;FONT face="Arial"&gt;(This assumes that &lt;FONT face="Courier New"&gt;number&lt;FONT face="Arial"&gt; is a value who's two's complement value is within the range of [-2^&lt;FONT face="Courier New"&gt;numBits&lt;FONT face="Arial"&gt;, 2^&lt;FONT face="Courier New"&gt;numBits&lt;FONT face="Arial"&gt;&amp;nbsp; - 1].&amp;nbsp; That is, no bits above &lt;FONT face="Courier New"&gt;numBits&lt;FONT face="Arial"&gt; are set.)&lt;BR /&gt;
&lt;BR /&gt;
As far as finding help, you can search for specific topics in the CVI
help by going to Help-&amp;gt;Contents then typing keywords into the Index
or Search tabs, but for things like data representaion or C language
specifics, you're probably more likely to find what you're looking for
in a good reference book or by searching the web.&lt;BR /&gt;
&lt;BR /&gt;
Hope this helps!&lt;BR /&gt;
&lt;BR /&gt;
Mert A.&lt;BR /&gt;
National Instruments&lt;BR /&gt;
&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
&lt;BR /&gt;
&lt;/FONT&gt;&lt;/FONT&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 21 Oct 2005 17:25:51 GMT</pubDate>
    <dc:creator>Mert_A.</dc:creator>
    <dc:date>2005-10-21T17:25:51Z</dc:date>
    <item>
      <title>2's complement</title>
      <link>https://ni.lithium.com/t5/LabWindows-CVI/2-s-complement/m-p/280341#M19081</link>
      <description>&lt;DIV&gt;I like to convert 0xFFFF ~ 0x8000 to -1~-32767 by use 2's complement method. &lt;/DIV&gt;
&lt;DIV&gt;I was not able to find in the online help, could someone tell me:&lt;/DIV&gt;
&lt;DIV&gt;1. How to do the 2's complement with CVI?&lt;/DIV&gt;
&lt;DIV&gt;2. How to find these kind of information in CVI help?&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Thanks a lot&lt;/DIV&gt;</description>
      <pubDate>Fri, 21 Oct 2005 16:37:58 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabWindows-CVI/2-s-complement/m-p/280341#M19081</guid>
      <dc:creator>FerroK</dc:creator>
      <dc:date>2005-10-21T16:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: 2's complement</title>
      <link>https://ni.lithium.com/t5/LabWindows-CVI/2-s-complement/m-p/280368#M19083</link>
      <description>&lt;DIV&gt;To get the the twos compliment of a number in C, multiply the number by -1.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;CVI does not provide a great deal of information on the ANSI C programming language beyond the function panels.&amp;nbsp; But documentation on the C language is readily available on the web.&amp;nbsp; Use google or your favorite search engine.&lt;/DIV&gt;
&lt;DIV&gt;Good Luck&lt;/DIV&gt;</description>
      <pubDate>Fri, 21 Oct 2005 17:19:35 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabWindows-CVI/2-s-complement/m-p/280368#M19083</guid>
      <dc:creator>mvr</dc:creator>
      <dc:date>2005-10-21T17:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: 2's complement</title>
      <link>https://ni.lithium.com/t5/LabWindows-CVI/2-s-complement/m-p/280370#M19084</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;Hello,&lt;BR /&gt;
&lt;BR /&gt;Signed integers are already represented using two's complement, so
if you are only concerned with 16-bit integers (like 0xFFFF and
0x8000), all you have to do is cast the value as a &lt;FONT face="Courier New"&gt;short int.&lt;FONT face="Arial"&gt; If you need to interpret other sizes, the general method would be this:&lt;BR /&gt;
&lt;BR /&gt;
&lt;FONT face="Courier New"&gt;int highBitMask = 1 &amp;lt;&amp;lt; (numBits - 1);&lt;BR /&gt;
&lt;BR /&gt;
(~highBitMask &amp;amp; number) - (highBitMask &amp;amp; number);&lt;BR /&gt;
&lt;BR /&gt;
&lt;FONT face="Arial"&gt;(This assumes that &lt;FONT face="Courier New"&gt;number&lt;FONT face="Arial"&gt; is a value who's two's complement value is within the range of [-2^&lt;FONT face="Courier New"&gt;numBits&lt;FONT face="Arial"&gt;, 2^&lt;FONT face="Courier New"&gt;numBits&lt;FONT face="Arial"&gt;&amp;nbsp; - 1].&amp;nbsp; That is, no bits above &lt;FONT face="Courier New"&gt;numBits&lt;FONT face="Arial"&gt; are set.)&lt;BR /&gt;
&lt;BR /&gt;
As far as finding help, you can search for specific topics in the CVI
help by going to Help-&amp;gt;Contents then typing keywords into the Index
or Search tabs, but for things like data representaion or C language
specifics, you're probably more likely to find what you're looking for
in a good reference book or by searching the web.&lt;BR /&gt;
&lt;BR /&gt;
Hope this helps!&lt;BR /&gt;
&lt;BR /&gt;
Mert A.&lt;BR /&gt;
National Instruments&lt;BR /&gt;
&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;
&lt;BR /&gt;
&lt;/FONT&gt;&lt;/FONT&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 21 Oct 2005 17:25:51 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabWindows-CVI/2-s-complement/m-p/280370#M19084</guid>
      <dc:creator>Mert_A.</dc:creator>
      <dc:date>2005-10-21T17:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: 2's complement</title>
      <link>https://ni.lithium.com/t5/LabWindows-CVI/2-s-complement/m-p/281024#M19100</link>
      <description>&lt;P&gt;If I remember my maths correctly (its been a while...) you&amp;nbsp;obtain the 2's complement of a number by first taking the 1's complement and then adding 1. So, in C:&lt;/P&gt;
&lt;BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px"&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;int number;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;int complement_2;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New"&gt;complement_2 = ~number + 1;&lt;/FONT&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;JR&lt;/P&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 24 Oct 2005 16:30:42 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabWindows-CVI/2-s-complement/m-p/281024#M19100</guid>
      <dc:creator>jr_2005</dc:creator>
      <dc:date>2005-10-24T16:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: 2's complement</title>
      <link>https://ni.lithium.com/t5/LabWindows-CVI/2-s-complement/m-p/281065#M19103</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Thanks for all your replys, after 5 years not touching C &amp;amp; CVI, I'm rusted... Your helps really put me back to programming mode. Thanks.&lt;/P&gt;
&lt;P&gt;FerroK&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2005 17:40:06 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabWindows-CVI/2-s-complement/m-p/281065#M19103</guid>
      <dc:creator>FerroK</dc:creator>
      <dc:date>2005-10-24T17:40:06Z</dc:date>
    </item>
  </channel>
</rss>

