<?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: Converting 16 Bit Integer to Individual Bits in LabVIEW</title>
    <link>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518299#M246306</link>
    <description>&lt;DIV&gt;&lt;/DIV&gt;Forgot to attach.</description>
    <pubDate>Wed, 09 May 2007 01:28:37 GMT</pubDate>
    <dc:creator>TMDATA</dc:creator>
    <dc:date>2007-05-09T01:28:37Z</dc:date>
    <item>
      <title>Converting 16 Bit Integer to Individual Bits</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518297#M246304</link>
      <description>&lt;DIV&gt;I have a 16 bit Binary Integer and I need to&amp;nbsp;convert this into&amp;nbsp;Individual bits so we can perform some&amp;nbsp;data manipulation.&amp;nbsp; I&amp;nbsp;know there is a easy solution, but I just cant figure it out.&amp;nbsp; I attached what I was trying to do,&amp;nbsp;remove the 16 bits and&amp;nbsp;make a 1D array&amp;nbsp;with 16 elements, then remove each element from the array.&amp;nbsp; This may be the wrong approach to this problem.&amp;nbsp; Any help would be appreciated.&amp;nbsp; Thanks in advance.&lt;/DIV&gt;</description>
      <pubDate>Wed, 09 May 2007 01:27:35 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518297#M246304</guid>
      <dc:creator>TMDATA</dc:creator>
      <dc:date>2007-05-09T01:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 16 Bit Integer to Individual Bits</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518299#M246306</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;Forgot to attach.</description>
      <pubDate>Wed, 09 May 2007 01:28:37 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518299#M246306</guid>
      <dc:creator>TMDATA</dc:creator>
      <dc:date>2007-05-09T01:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 16 Bit Integer to Individual Bits</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518676#M246464</link>
      <description>Hmmm.. at first I wondered: what is a 16-bit &lt;I&gt;binary&lt;/I&gt; integer? Never heard of that one. Oh, it's a control set to display in binary mode. Ah....&lt;BR /&gt;&lt;BR /&gt;I'm not sure I completely understand your end goal. Do you want an array of bits? If so, just use the "Number to Boolean Array" function. Do you need this to be an array of ones and zeros? Then wire the output of the "Number to Boolean Array" to the "Boolean to (1,0)" function.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 09 May 2007 14:19:04 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518676#M246464</guid>
      <dc:creator>smercurio_fc</dc:creator>
      <dc:date>2007-05-09T14:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 16 Bit Integer to Individual Bits</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518783#M246499</link>
      <description>&lt;DIV&gt;Yep thats what I wanted.&amp;nbsp; Take the&amp;nbsp;16bits convert them to boolean array, then boolean to (0,1) array.&amp;nbsp; Then I could seperate&amp;nbsp;out each one in the array.&amp;nbsp; Thanks for your help.&lt;/DIV&gt;</description>
      <pubDate>Wed, 09 May 2007 16:10:04 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518783#M246499</guid>
      <dc:creator>TMDATA</dc:creator>
      <dc:date>2007-05-09T16:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 16 Bit Integer to Individual Bits</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518806#M246510</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;If you just need to manipulate&amp;nbsp;a few&amp;nbsp;bits, it is relatively expensive to go the detour via boolean arrays and integer arrays. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Most of the time you can get the desired operation directly via boolean operations on the&amp;nbsp;original number&amp;nbsp;(masking, combining,&amp;nbsp;etc.).&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;(For a comparison, have a look a the &lt;A href="http://zone.ni.com/devzone/cda/tut/p/id/5307" target="_blank"&gt;results&lt;/A&gt; of the &lt;A href="http://zone.ni.com/devzone/cda/tut/p/id/5306" target="_blank"&gt;Bit twiddling challenge&lt;/A&gt; from a few years ago. Solutions involving a detour via boolean arrays took tens of seconds while direct bit operations did the same tasks in under 100ms. If this is a core part of your code that needs to run in an inner loop with lots of data, optimization with be important.)&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;What do you actually need to do &lt;U&gt;overall&lt;/U&gt;? I am pretty sure there is a better way. Looking at your code, it seems you just want to scale your integer into a fixed point implementation. Most likely, all you need is to divide your input by an integer power of two. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Keep it simple! (The code you posted is incredibly convoluted!)&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;Message Edited by altenbach on &lt;SPAN class="date_text"&gt;05-09-2007&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;09:33 AM&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2007 16:31:56 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518806#M246510</guid>
      <dc:creator>altenbach</dc:creator>
      <dc:date>2007-05-09T16:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 16 Bit Integer to Individual Bits</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518824#M246514</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;Yeah, well I couldn't quite figure our what he (or she) wanted either, so I just went by the statement that he wanted individual bits and suggested those two functions to get the array of individual bits. I agree that if the end goal is something else, then a better solution would likely not rely on the use of arrays, and I was not implying by my response that what I suggested was the only (or best) method.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;P&gt;Message Edited by smercurio_fc on &lt;SPAN class="date_text"&gt;05-09-2007&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;11:50 AM&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2007 16:49:56 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518824#M246514</guid>
      <dc:creator>smercurio_fc</dc:creator>
      <dc:date>2007-05-09T16:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 16 Bit Integer to Individual Bits</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518846#M246521</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;It seems your input is a I16 integer, so it is really bad to have the representation of the control as U32. Makes no sense.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Anyway, here's a quick alternative that seems to give the desired result with a code size of less than a postage stamp. see if it works for you. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;IMG src="http://forums.ni.com/attachments/ni/170/246521/1/scaleInteger.png" /&gt;&lt;/DIV&gt;
&lt;P&gt;(note that we get different results for some input values. Do you have the original documentation for the conversion?)&lt;/P&gt;&lt;P&gt;Message Edited by altenbach on &lt;SPAN class="date_text"&gt;05-09-2007&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;10:25 AM&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2007 17:14:11 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518846#M246521</guid>
      <dc:creator>altenbach</dc:creator>
      <dc:date>2007-05-09T17:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 16 Bit Integer to Individual Bits</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518857#M246526</link>
      <description>&lt;DIV&gt;I am getting a 16.12 bit signed binary number.&amp;nbsp; The first bit&amp;nbsp;is multiplied&amp;nbsp;by -2^3, the second bit&amp;nbsp;is multiplied by 2^2, third bit by&amp;nbsp;2^1, fourth bit by&amp;nbsp;2^0 then the rest are&amp;nbsp;of bits are multiplied by&amp;nbsp;2^-1, 2^-2, 2^-3... and so on until&amp;nbsp;2^-12 to convert them to decimal.&amp;nbsp; Then all of these are to be added up.&amp;nbsp; That is what I am trying to do.&amp;nbsp; I am sure there is a better way to do this.&amp;nbsp; &lt;/DIV&gt;</description>
      <pubDate>Wed, 09 May 2007 17:28:31 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518857#M246526</guid>
      <dc:creator>TMDATA</dc:creator>
      <dc:date>2007-05-09T17:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 16 Bit Integer to Individual Bits</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518909#M246538</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;
&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/39459"&gt;@TMDATA&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;DIV&gt;I am getting a 16.12 bit signed binary number.&amp;nbsp; The first bit&amp;nbsp;is multiplied&amp;nbsp;by -2^3, the second bit&amp;nbsp;is multiplied by 2^2, third bit by&amp;nbsp;2^1, fourth bit by&amp;nbsp;2^0 then the rest are&amp;nbsp;of bits are multiplied by&amp;nbsp;2^-1, 2^-2, 2^-3... and so on until&amp;nbsp;2^-12 to convert them to decimal.&amp;nbsp; Then all of these are to be added up.&amp;nbsp; That is what I am trying to do.&amp;nbsp; I am sure there is a better way to do this.&lt;BR /&gt;
&lt;HR /&gt;
&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;OK, that's exacty what my code posted above does! Simple enough? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://forums.ni.com/attachments/ni/170/246521/1/scaleInteger.png" /&gt;&lt;/P&gt;
&lt;P&gt;(Even simpler, you can fold the power of two&amp;nbsp;calculation&amp;nbsp;into a diagram constant.)&lt;/P&gt;
&lt;P&gt;The results are not always the same because &lt;STRONG&gt;you &lt;/STRONG&gt;have a wiring mistake as shown in the picture.&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://forums.ni.com/attachments/ni/170/246538/1/miswired.png" /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Message Edited by altenbach on &lt;SPAN class="date_text"&gt;05-09-2007&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;11:41 AM&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2007 18:38:27 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518909#M246538</guid>
      <dc:creator>altenbach</dc:creator>
      <dc:date>2007-05-09T18:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: Converting 16 Bit Integer to Individual Bits</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518925#M246546</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;Yeah I caught that this morning that the wire was on the wrong one.&amp;nbsp; I guess thats even more of a reason to make the code simple!&amp;nbsp; Thanks for the time and effort.&amp;nbsp;</description>
      <pubDate>Wed, 09 May 2007 19:18:18 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Converting-16-Bit-Integer-to-Individual-Bits/m-p/518925#M246546</guid>
      <dc:creator>TMDATA</dc:creator>
      <dc:date>2007-05-09T19:18:18Z</dc:date>
    </item>
  </channel>
</rss>

