<?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[Ausdrücke und Anweisungen (Verständnissfrage)]]></title><description><![CDATA[<p>Also ich habe ein kleines Problem, zuerst dachte ich das es eine klare Sache ist. Löste die Aufgabe und überprüfte sie dann noch mal in dem Kompiler.</p>
<ol>
<li></li>
</ol>
<p>if(2 &lt; 4 || 2 - 3 &lt; 0 &amp;&amp; 2 &gt;= 7)<br />
(Kompiler sagt =&gt; True)<br />
2.<br />
if(2 - 3 != 0 &amp;&amp; 3 % 2 == 1)<br />
(Kompiler sagt =&gt; True)<br />
3.<br />
float x = 1 + 1 / 2<br />
(Kompiler sagt =&gt; x = 1 )</p>
<p>1. OK || hat eine höhere Priorität als &amp;&amp; das hab ich ja noch akzeptiert<br />
2. War ich auch mit einverstanden<br />
3. Ich wäre jede Wette eingegangen das dort als Ergebniss 1.5 raus kommt ( da / eine höhere Priorität hat als + )<br />
Oder wird da nun doch von links nach rechts gerechnet ? ( also ich habs anders in erinnerung <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> )</p>
<p>Hab ich da nur etwas falsch in erinnerung oder ist jemand so nett und erklärt es mir <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/172401/ausdrücke-und-anweisungen-verständnissfrage</link><generator>RSS for Node</generator><lastBuildDate>Thu, 17 Sep 2026 18:01:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/172401.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 04 Feb 2007 18:43:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ausdrücke und Anweisungen (Verständnissfrage) on Sun, 04 Feb 2007 18:43:57 GMT]]></title><description><![CDATA[<p>Also ich habe ein kleines Problem, zuerst dachte ich das es eine klare Sache ist. Löste die Aufgabe und überprüfte sie dann noch mal in dem Kompiler.</p>
<ol>
<li></li>
</ol>
<p>if(2 &lt; 4 || 2 - 3 &lt; 0 &amp;&amp; 2 &gt;= 7)<br />
(Kompiler sagt =&gt; True)<br />
2.<br />
if(2 - 3 != 0 &amp;&amp; 3 % 2 == 1)<br />
(Kompiler sagt =&gt; True)<br />
3.<br />
float x = 1 + 1 / 2<br />
(Kompiler sagt =&gt; x = 1 )</p>
<p>1. OK || hat eine höhere Priorität als &amp;&amp; das hab ich ja noch akzeptiert<br />
2. War ich auch mit einverstanden<br />
3. Ich wäre jede Wette eingegangen das dort als Ergebniss 1.5 raus kommt ( da / eine höhere Priorität hat als + )<br />
Oder wird da nun doch von links nach rechts gerechnet ? ( also ich habs anders in erinnerung <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> )</p>
<p>Hab ich da nur etwas falsch in erinnerung oder ist jemand so nett und erklärt es mir <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1222873</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1222873</guid><dc:creator><![CDATA[Deltaone]]></dc:creator><pubDate>Sun, 04 Feb 2007 18:43:57 GMT</pubDate></item><item><title><![CDATA[Reply to Ausdrücke und Anweisungen (Verständnissfrage) on Sun, 04 Feb 2007 18:57:14 GMT]]></title><description><![CDATA[<p>Versuch es mal so, dann sollte es funktionieren:</p>
<pre><code class="language-cpp">float x = 1 + 1.0 / 2
</code></pre>
<p>Das Problem ist, dass du mit int-Werten rechnest, dabei wird 1/2 zu 0. Erst bei der Zuweisung/Initialisierung wird ein float daraus und dann ist das Ergebnis schon &quot;falsch&quot;.<br />
&quot;Punkt vor Strich&quot; gilt natürlich. Das Ergebnis bleibt z.B. dasselbe, wenn du Klammern setzt:</p>
<pre><code class="language-cpp">float x = 1 + (1 / 2)
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1222883</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1222883</guid><dc:creator><![CDATA[Nanuq]]></dc:creator><pubDate>Sun, 04 Feb 2007 18:57:14 GMT</pubDate></item><item><title><![CDATA[Reply to Ausdrücke und Anweisungen (Verständnissfrage) on Sun, 04 Feb 2007 19:05:39 GMT]]></title><description><![CDATA[<p>Ah vielen dank, und das ||eine höhere Priorität als &amp;&amp; ist auch richtig ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1222890</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1222890</guid><dc:creator><![CDATA[Deltaone]]></dc:creator><pubDate>Sun, 04 Feb 2007 19:05:39 GMT</pubDate></item><item><title><![CDATA[Reply to Ausdrücke und Anweisungen (Verständnissfrage) on Sun, 04 Feb 2007 19:15:18 GMT]]></title><description><![CDATA[<p>Nein, ist genau andersherum, du könntest also so schreiben:</p>
<pre><code class="language-cpp">if(2 &lt; 4 || (2 - 3 &lt; 0 &amp;&amp; 2 &gt;= 7))
</code></pre>
<p>Der &quot;UND-Ausdruck wird zuerst ausgewertet, ergibt false, 2&lt;4 ergibt true, ergibt insgesamt true.</p>
<p>Edit: Hier kannst du die Priorität der Operatoren nochmal nachschauen:<br />
<a href="http://de.wikibooks.org/wiki/C++-Programmierung:_Liste_der_Operatoren_nach_Priorit%C3%A4t" rel="nofollow">http://de.wikibooks.org/wiki/C++-Programmierung:_Liste_der_Operatoren_nach_Priorität</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1222894</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1222894</guid><dc:creator><![CDATA[Nanuq]]></dc:creator><pubDate>Sun, 04 Feb 2007 19:15:18 GMT</pubDate></item></channel></rss>