<?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 Modulo]]></title><description><![CDATA[<p>Hallo,</p>
<p>was genau ist dieses &quot;Modulo&quot; ok %2 das weiss ich was das ist damit kann ich überprüfen ob bei der Division ein Rest enstanden ist oder nicht.</p>
<p>Ich hab vor ein paar Tagen mal einen Quelltext gefunden da drin stand %24<br />
Ich habe mal verschiedene Modulo Sachen ausprobiert aber irgendwie weiss ich nicht was das % da genau macht.</p>
<p>Warum bekomme ich hier bei %24 eine 4 ausgeben und bei %3 eine 1 ?<br />
Was genau rechnet den der PC da?</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std; 

int main(int argc, char* argv[])
 { 

int erg;

erg = 8 / 2;  

cout&lt;&lt;&quot;Ergeniss: &quot; &lt;&lt; erg &lt;&lt; endl
    &lt;&lt;&quot;Rest: &quot; &lt;&lt; erg % 2&lt;&lt; endl;  // Gibt 0 aus

cout&lt;&lt;&quot;Modulo 3: &quot; &lt;&lt; erg % 3 &lt;&lt; endl ;   // Gibt 1 aus
cout&lt;&lt;&quot;Modulo 5: &quot; &lt;&lt; erg % 5 &lt;&lt; endl ;   // Gibt 4 aus
cout&lt;&lt;&quot;Modulo 24: &quot; &lt;&lt; erg % 24 &lt;&lt; endl ; // Gibt 4 aus

system(&quot;PAUSE&quot;);
 }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/289535/frage-zu-modulo</link><generator>RSS for Node</generator><lastBuildDate>Wed, 19 Aug 2026 02:53:21 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/289535.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 07 Jul 2011 08:54:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Frage zu Modulo on Thu, 07 Jul 2011 08:54:57 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>was genau ist dieses &quot;Modulo&quot; ok %2 das weiss ich was das ist damit kann ich überprüfen ob bei der Division ein Rest enstanden ist oder nicht.</p>
<p>Ich hab vor ein paar Tagen mal einen Quelltext gefunden da drin stand %24<br />
Ich habe mal verschiedene Modulo Sachen ausprobiert aber irgendwie weiss ich nicht was das % da genau macht.</p>
<p>Warum bekomme ich hier bei %24 eine 4 ausgeben und bei %3 eine 1 ?<br />
Was genau rechnet den der PC da?</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std; 

int main(int argc, char* argv[])
 { 

int erg;

erg = 8 / 2;  

cout&lt;&lt;&quot;Ergeniss: &quot; &lt;&lt; erg &lt;&lt; endl
    &lt;&lt;&quot;Rest: &quot; &lt;&lt; erg % 2&lt;&lt; endl;  // Gibt 0 aus

cout&lt;&lt;&quot;Modulo 3: &quot; &lt;&lt; erg % 3 &lt;&lt; endl ;   // Gibt 1 aus
cout&lt;&lt;&quot;Modulo 5: &quot; &lt;&lt; erg % 5 &lt;&lt; endl ;   // Gibt 4 aus
cout&lt;&lt;&quot;Modulo 24: &quot; &lt;&lt; erg % 24 &lt;&lt; endl ; // Gibt 4 aus

system(&quot;PAUSE&quot;);
 }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2089809</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2089809</guid><dc:creator><![CDATA[modulo]]></dc:creator><pubDate>Thu, 07 Jul 2011 08:54:57 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Modulo on Thu, 07 Jul 2011 09:04:38 GMT]]></title><description><![CDATA[<p><a href="http://de.wikipedia.org/wiki/Division_mit_Rest#Modulo" rel="nofollow">http://de.wikipedia.org/wiki/Division_mit_Rest#Modulo</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2089812</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2089812</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 07 Jul 2011 09:04:38 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Modulo on Thu, 07 Jul 2011 09:04:49 GMT]]></title><description><![CDATA[<p>a%b ist der Rest, der bei der Division a/b entsteht.</p>
<p>Bei 4 % 24 bekommst du deshalb 4 zurück, weil 4/24 = 0 mit Rest 4. Bei 4 % 3 bekommst du 1, weil 4/3 = 1 mit Rest 1</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2089813</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2089813</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Thu, 07 Jul 2011 09:04:49 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Modulo on Thu, 07 Jul 2011 11:13:29 GMT]]></title><description><![CDATA[<p>% ist der Divisionsrest bei der Ganzzahldivision. Also,</p>
<pre><code>(a/b)*b + a%b == a    für b!=0
</code></pre>
<p>Beispiel mit a=12, b=5</p>
<pre><code>(12/5)*5 + 12%5 == 12
   2         
   \  /      2
    10
      \    /
        12
          \         /
             true
</code></pre>
<p>% kann u.U. aber auch negative Zahlen zurückgeben, wohingegen man <a href="http://de.wikipedia.org/wiki/Restklasse" rel="nofollow">Restklassen</a> <em>typischerweise</em> mit Zahlen repräsentiert, die nicht negativ sind.</p>
<blockquote>
<pre><code>erg = 4;
cout&lt;&lt;&quot;Modulo  2: &quot; &lt;&lt; erg %  2 &lt;&lt; endl; // Gibt 0 aus
cout&lt;&lt;&quot;Modulo  3: &quot; &lt;&lt; erg %  3 &lt;&lt; endl; // Gibt 1 aus
cout&lt;&lt;&quot;Modulo  5: &quot; &lt;&lt; erg %  5 &lt;&lt; endl; // Gibt 4 aus
cout&lt;&lt;&quot;Modulo 24: &quot; &lt;&lt; erg % 24 &lt;&lt; endl; // Gibt 4 aus
</code></pre>
</blockquote>
<p>(von mir editiert)</p>
<p>Ist doch jetzt klar, wieso da 0,1,4,4 rauskommt, oder?</p>
<p>kk</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2089854</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2089854</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Thu, 07 Jul 2011 11:13:29 GMT</pubDate></item></channel></rss>