<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Frage zu PopulationCount algorithmus]]></title><description><![CDATA[<p>Hallo, auf <a href="http://graphics.stanford.edu/~seander/bithacks.html" rel="nofollow">http://graphics.stanford.edu/~seander/bithacks.html</a> habe ich diesen Algorithmus zum Zählen der gesetzten bits gefunden:</p>
<pre><code class="language-cpp">v = v - ((v &gt;&gt; 1) &amp; (T)~(T)0/3);                           // temp
v = (v &amp; (T)~(T)0/15*3) + ((v &gt;&gt; 2) &amp; (T)~(T)0/15*3);      // temp
v = (v + (v &gt;&gt; 4)) &amp; (T)~(T)0/255*15;                      // temp
c = (T)(v * ((T)~(T)0/255)) &gt;&gt; (sizeof(v) - 1) * CHAR_BIT; // count
</code></pre>
<p>Als Beschreiung stand dort:<br />
&quot;A generalization of the best bit counting method to integers of bit-widths upto 128 (parameterized by type T) is this&quot;</p>
<p>Warum &quot;upto 128&quot;? Ich sehe keine Begrenzung in dem Code, die die Gültigkeit nur bis 128 garantiert. Oder irre ich mich?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/265564/frage-zu-populationcount-algorithmus</link><generator>RSS for Node</generator><lastBuildDate>Thu, 03 Sep 2026 21:35:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/265564.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 25 Apr 2010 14:23:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Frage zu PopulationCount algorithmus on Sun, 25 Apr 2010 14:23:28 GMT]]></title><description><![CDATA[<p>Hallo, auf <a href="http://graphics.stanford.edu/~seander/bithacks.html" rel="nofollow">http://graphics.stanford.edu/~seander/bithacks.html</a> habe ich diesen Algorithmus zum Zählen der gesetzten bits gefunden:</p>
<pre><code class="language-cpp">v = v - ((v &gt;&gt; 1) &amp; (T)~(T)0/3);                           // temp
v = (v &amp; (T)~(T)0/15*3) + ((v &gt;&gt; 2) &amp; (T)~(T)0/15*3);      // temp
v = (v + (v &gt;&gt; 4)) &amp; (T)~(T)0/255*15;                      // temp
c = (T)(v * ((T)~(T)0/255)) &gt;&gt; (sizeof(v) - 1) * CHAR_BIT; // count
</code></pre>
<p>Als Beschreiung stand dort:<br />
&quot;A generalization of the best bit counting method to integers of bit-widths upto 128 (parameterized by type T) is this&quot;</p>
<p>Warum &quot;upto 128&quot;? Ich sehe keine Begrenzung in dem Code, die die Gültigkeit nur bis 128 garantiert. Oder irre ich mich?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1888079</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1888079</guid><dc:creator><![CDATA[Bitchecker]]></dc:creator><pubDate>Sun, 25 Apr 2010 14:23:28 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu PopulationCount algorithmus on Tue, 27 Apr 2010 00:08:19 GMT]]></title><description><![CDATA[<p>Hat niemand eine Antwort? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1888738</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1888738</guid><dc:creator><![CDATA[Bitchecker]]></dc:creator><pubDate>Tue, 27 Apr 2010 00:08:19 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu PopulationCount algorithmus on Tue, 27 Apr 2010 06:40:39 GMT]]></title><description><![CDATA[<p>Nö, ich kapier ned mal die erste Zeile.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1888773</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1888773</guid><dc:creator><![CDATA[PlxDontComment]]></dc:creator><pubDate>Tue, 27 Apr 2010 06:40:39 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu PopulationCount algorithmus on Tue, 27 Apr 2010 06:52:10 GMT]]></title><description><![CDATA[<p>Du hättest gleich den richtigen Link posten können, so muss man erst auf der ewig langen Seite suchen.<br />
<a href="http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel" rel="nofollow">http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel</a><br />
Sonst weiß echt niemenad, was &quot;v&quot;, &quot;c&quot; oder &quot;T&quot; sein sollen.<br />
Außerdem sind doch darunter noch massig Links, hast du da mal reingeschaut?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1888780</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1888780</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or]]></dc:creator><pubDate>Tue, 27 Apr 2010 06:52:10 GMT</pubDate></item></channel></rss>