<?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[dualzahl shiften?]]></title><description><![CDATA[<p>Hi Leute! Ich hab folgenden code:</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;
using namespace std;

int main()
{
    unsigned char a0, a1, a2, b0, b1, b2;
    unsigned short int a, b;
    unsigned short int i, x, z7, z6, z5, z4, z3, z2, z1, z0, y7, y6, y5, y4, 

a=235
b=121

     x = (a &amp; 00000001);
     z0 = x;

     x = (a &amp; 00000010);
     z1 = x &gt;&gt; 1;

     x = a &amp; 00000100;
     z2 = x &gt;&gt; 7;

     x = a &amp; 00001000;
     z3 = x &gt;&gt; 11;

    cout &lt;&lt; &quot;Dualzahl= &quot; &lt;&lt; z3 &lt;&lt; z2 &lt;&lt; z1 &lt;&lt; z0 &lt;&lt; endl;

    system(&quot;pause&quot;);
    return 0;
}
</code></pre>
<p>wenn ich hier nun die 1. ziffer in die z0 schreib, dann passt die... die zweite maskier ich nun mit 00000010 und verodere mit a und shifte um eins nach rechts. da bringt er mir dann aber das falsche...</p>
<p>Könnt ihr mir helfen was da faul ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/276566/dualzahl-shiften</link><generator>RSS for Node</generator><lastBuildDate>Wed, 26 Aug 2026 09:37:09 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/276566.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Nov 2010 16:35:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to dualzahl shiften? on Thu, 04 Nov 2010 16:35:10 GMT]]></title><description><![CDATA[<p>Hi Leute! Ich hab folgenden code:</p>
<pre><code class="language-cpp">#include&lt;iostream&gt;
using namespace std;

int main()
{
    unsigned char a0, a1, a2, b0, b1, b2;
    unsigned short int a, b;
    unsigned short int i, x, z7, z6, z5, z4, z3, z2, z1, z0, y7, y6, y5, y4, 

a=235
b=121

     x = (a &amp; 00000001);
     z0 = x;

     x = (a &amp; 00000010);
     z1 = x &gt;&gt; 1;

     x = a &amp; 00000100;
     z2 = x &gt;&gt; 7;

     x = a &amp; 00001000;
     z3 = x &gt;&gt; 11;

    cout &lt;&lt; &quot;Dualzahl= &quot; &lt;&lt; z3 &lt;&lt; z2 &lt;&lt; z1 &lt;&lt; z0 &lt;&lt; endl;

    system(&quot;pause&quot;);
    return 0;
}
</code></pre>
<p>wenn ich hier nun die 1. ziffer in die z0 schreib, dann passt die... die zweite maskier ich nun mit 00000010 und verodere mit a und shifte um eins nach rechts. da bringt er mir dann aber das falsche...</p>
<p>Könnt ihr mir helfen was da faul ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1975179</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1975179</guid><dc:creator><![CDATA[bandchef]]></dc:creator><pubDate>Thu, 04 Nov 2010 16:35:10 GMT</pubDate></item><item><title><![CDATA[Reply to dualzahl shiften? on Thu, 04 Nov 2010 17:00:16 GMT]]></title><description><![CDATA[<p>Du meinst wohl UND statt ODER.<br />
Außerdem sind in deinem Programm noch ein paar mehr Fehler, beispielsweise die 11.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1975201</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1975201</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 04 Nov 2010 17:00:16 GMT</pubDate></item><item><title><![CDATA[Reply to dualzahl shiften? on Thu, 04 Nov 2010 23:11:11 GMT]]></title><description><![CDATA[<p>Ich bin mir nicht sicher ob ich dein vorhaben richtig verstanden habe.<br />
Es sieht so aus als möchtest du einen Dezimalzahl a=235 als Dualzahl ausgeben oder?</p>
<p>Die Masken die du verwendest sind in Oktaldarstellung(wegen der führenden 0) d.h.<br />
deine erste Bitmaske 00000001(Oktal) = 1(Dezimal) = 00000001(Dual) stimmt weil in allen Zahlensystem die Darstellung 1=1 ist, deine Zweite wird aber so aussehen: 00000010(Oktal) = 8(Dezimal) = 00001000(Dual) und damit ist das nicht die Maske die du haben willst. Die Masken die du haben willst entsprechen den Zweierpotenzen 1,2,4,8,...</p>
<p>Deine Shifts sind auch zu viel. Mit x&gt;&gt;7 schiebst du 7 bits weiter, du willst an dieser Stelle aber nur 2 schieben...</p>
<p>EDIT: Semicolons fehlen im Code auch noch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1975468</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1975468</guid><dc:creator><![CDATA[JaykopX]]></dc:creator><pubDate>Thu, 04 Nov 2010 23:11:11 GMT</pubDate></item><item><title><![CDATA[Reply to dualzahl shiften? on Fri, 05 Nov 2010 00:11:53 GMT]]></title><description><![CDATA[<p>Das Problem in c++ ist, dass die schreibweise 00001111 eine oktalzahl ist.<br />
für binärzahlen gibt es soweit ich weis keine schreibweise, aber was du<br />
sehr einfach machen kannst (wo du gerade beim shiften bist):</p>
<p>00000001 entspricht 1<br />
00000010 entspricht (1&lt;&lt;1)<br />
00000100 entspricht (1&lt;&lt;2)<br />
00001000 entspricht (1&lt;&lt;3)</p>
<p>usw... bis (1&lt;&lt;7)</p>
<p>sieht dann ungefähr so aus:</p>
<pre><code class="language-cpp">[code]#include&lt;iostream&gt;
using namespace std;

int main()
{
	unsigned char a0, a1, a2, b0, b1, b2;
	unsigned short int a, b;
	unsigned short int i, x, z7, z6, z5, z4, z3, z2, z1, z0, y7, y6, y5, y4;

	a=235;
	b=121;

	x = (a &amp; 1);      // a &amp; 00000001 bzw. a &amp; 0x01
	z0 = x;

	x = (a &amp; (1&lt;&lt;1)); // a &amp; 00000010 bzw. a &amp; 0x02
	z1 = x &gt;&gt; 1;

	x = a &amp; (1&lt;&lt;2);   // a &amp; 00000100 bzw. a &amp; 0x04
	z2 = x &gt;&gt; 2;

	x = a &amp; (1&lt;&lt;3);   // a &amp; 00001000 bzw. a &amp; 0x08
	z3 = x &gt;&gt; 3;   

	cout &lt;&lt; &quot;Dualzahl= &quot; &lt;&lt; z3 &lt;&lt; z2 &lt;&lt; z1 &lt;&lt; z0 &lt;&lt; endl;

	system(&quot;pause&quot;);
	return 0;
}
</code></pre>
<p>Ansonsten kannst du dir mit hilfe eines Taschenrechners die Dualzahl in einen Hex wert umrechnen</p>
<p>z.B. 00110101 -&gt; 0x35<br />
sieht dann bei einem beispiel so aus: x = (a &amp; 0x04);</p>
<p>Bei deinen Beispielen ist das aber sowieso relativ angenehm zu rechnen, da du ja nur jeweils 1 bit rausfiltern willst über das logische und.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1975479</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1975479</guid><dc:creator><![CDATA[Calurader]]></dc:creator><pubDate>Fri, 05 Nov 2010 00:11:53 GMT</pubDate></item></channel></rss>