<?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[double kürzen bzw. ohne kommastellen]]></title><description><![CDATA[<p>hallo, ich hab da mal ne kleine frage. wie kann ich nen double so kürzen, dass er keine zeichen nach dem komma anzeigt?<br />
ich hab da das schachbrett-könig teil programmiert, also auf jedem feld die doppelte menge reiskörner <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
nur leider gibt der mir folgendes aus:<br />
Auf Feld 1.000000 liegen 1.000000 Körner. Nun will ich aber, dass der nur &quot;Auf Feld 1 liegen 1 Körner&quot; ausgibt. Nen integer oder so kann ich ja leider nicht nehmen, da die zahl recht gross wird <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>hier mal der code.</p>
<pre><code class="language-cpp">void main(void)
{
	double start_anzahl = 1;
	double max_felder = 64;
	double i;

	for(i = 1; i &lt;= max_felder; i++){
		printf(&quot;Auf Feld %lf liegen %lf Koerner!\n&quot;,i, start_anzahl);
		start_anzahl*= 2;
	}
	system(&quot;pause&quot;);
}
</code></pre>
<p>danke schonmal im voraus.</p>
<p>gruss</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/152295/double-kürzen-bzw-ohne-kommastellen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 06 Sep 2026 21:48:19 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/152295.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 05 Jul 2006 08:37:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to double kürzen bzw. ohne kommastellen on Wed, 05 Jul 2006 08:37:26 GMT]]></title><description><![CDATA[<p>hallo, ich hab da mal ne kleine frage. wie kann ich nen double so kürzen, dass er keine zeichen nach dem komma anzeigt?<br />
ich hab da das schachbrett-könig teil programmiert, also auf jedem feld die doppelte menge reiskörner <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
nur leider gibt der mir folgendes aus:<br />
Auf Feld 1.000000 liegen 1.000000 Körner. Nun will ich aber, dass der nur &quot;Auf Feld 1 liegen 1 Körner&quot; ausgibt. Nen integer oder so kann ich ja leider nicht nehmen, da die zahl recht gross wird <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>hier mal der code.</p>
<pre><code class="language-cpp">void main(void)
{
	double start_anzahl = 1;
	double max_felder = 64;
	double i;

	for(i = 1; i &lt;= max_felder; i++){
		printf(&quot;Auf Feld %lf liegen %lf Koerner!\n&quot;,i, start_anzahl);
		start_anzahl*= 2;
	}
	system(&quot;pause&quot;);
}
</code></pre>
<p>danke schonmal im voraus.</p>
<p>gruss</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1091587</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091587</guid><dc:creator><![CDATA[nonN]]></dc:creator><pubDate>Wed, 05 Jul 2006 08:37:26 GMT</pubDate></item><item><title><![CDATA[Reply to double kürzen bzw. ohne kommastellen on Wed, 05 Jul 2006 08:40:06 GMT]]></title><description><![CDATA[<p>Also für die Felderzahl (i) reicht ein int auf jeden Fall aus. Und für die Ausgabe der double-Werte probier's mal mit der Angabe &quot;%.0lf&quot; (Präzision (Nachkommastellen) = 0).</p>
<p>(PS: C ist eine Etage höher)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1091588</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091588</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 05 Jul 2006 08:40:06 GMT</pubDate></item><item><title><![CDATA[Reply to double kürzen bzw. ohne kommastellen on Wed, 05 Jul 2006 08:43:06 GMT]]></title><description><![CDATA[<p>hehe es is aber ned C <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_tongue"
      title=":P"
      alt="😛"
    /><br />
hab nur printf genommen um das teil zu testen <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="😉"
    /> is ne .cpp datei</p>
<p>naja, wenn ich nen int nehm bei einer zahl, dann gibt er mir nur 0 aus und das ist auch nicht so richtig <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /><br />
das mit dem kürzen versuch ich eben mal.</p>
<p>greetz</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1091592</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091592</guid><dc:creator><![CDATA[nonN]]></dc:creator><pubDate>Wed, 05 Jul 2006 08:43:06 GMT</pubDate></item><item><title><![CDATA[Reply to double kürzen bzw. ohne kommastellen on Wed, 05 Jul 2006 08:47:43 GMT]]></title><description><![CDATA[<p>Wenn du einen int-Wert mit &quot;%lf&quot; ausgeben willst, dürfte sowieso nur Müll entstehen - deswegen verwendet man in C++ auch IO-Streams für so etwas (die wissen zur Compilezeit, was für ein Typ ankommt und wie sie ihn verarbeiten müssen):</p>
<pre><code class="language-cpp">int main(void) // btw, &quot;void main()&quot; ist Unsinn
{
    double start_anzahl = 1;
    int max_felder = 64;
    cout&lt;&lt;setprecision(0)&lt;&lt;noshowpoint;//Ausgabe anpassen

    for(int i = 1; i &lt;= max_felder; i++){
        cout&lt;&lt;&quot;Auf Feld &quot;&lt;&lt;i&lt;&lt;&quot; liegen &quot;&lt;&lt;start_anzahl&lt;&lt;&quot; Körner.\n&quot;;
        start_anzahl*= 2;
    }
    //system(&quot;pause&quot;);
    cin.get();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1091595</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091595</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 05 Jul 2006 08:47:43 GMT</pubDate></item><item><title><![CDATA[Reply to double kürzen bzw. ohne kommastellen on Wed, 05 Jul 2006 09:04:56 GMT]]></title><description><![CDATA[<p>hm okee, ich merks mir. danke vielmals <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>gruss</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1091619</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1091619</guid><dc:creator><![CDATA[nonN]]></dc:creator><pubDate>Wed, 05 Jul 2006 09:04:56 GMT</pubDate></item></channel></rss>