<?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[Auf x stellen nach dem Komma runden?]]></title><description><![CDATA[<p>Hallo wie kann man in C++ auf x stellen nach dem Komma runden?<br />
z.b.:<br />
3 Stellen nach dem Komma<br />
14.125489 = 14.125<br />
17.245667 = 17.246<br />
21.111222 = 21.111<br />
usw..</p>
<p>Und dann wüsste ich noch gerne wie man die Wurze ziehen kann, also jetzt nicht die Quadratwurzel mit sqrt() sondern die x wurzel aus y</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/190126/auf-x-stellen-nach-dem-komma-runden</link><generator>RSS for Node</generator><lastBuildDate>Fri, 25 Sep 2026 12:56:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/190126.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 20 Aug 2007 01:38:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 01:42:09 GMT]]></title><description><![CDATA[<p>Hallo wie kann man in C++ auf x stellen nach dem Komma runden?<br />
z.b.:<br />
3 Stellen nach dem Komma<br />
14.125489 = 14.125<br />
17.245667 = 17.246<br />
21.111222 = 21.111<br />
usw..</p>
<p>Und dann wüsste ich noch gerne wie man die Wurze ziehen kann, also jetzt nicht die Quadratwurzel mit sqrt() sondern die x wurzel aus y</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1347829</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1347829</guid><dc:creator><![CDATA[lord_fritte]]></dc:creator><pubDate>Mon, 20 Aug 2007 01:42:09 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 05:06:56 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
#include&lt;iomanip&gt;

int main( ) {

    std::cout &lt;&lt; std::fixed &lt;&lt; std::setprecision( 3 ) &lt;&lt; 14.125489 &lt;&lt; std::endl;
    std::cout &lt;&lt; std::fixed &lt;&lt; std::setprecision( 3 ) &lt;&lt; 17.245667 &lt;&lt; std::endl;
    std::cout &lt;&lt; std::fixed &lt;&lt; std::setprecision( 3 ) &lt;&lt; 21.111222 &lt;&lt; std::endl;
}
</code></pre>
<pre><code class="language-cpp">#include &lt;cmath&gt;

inline double sqrtn( double x, double n ) {
    return pow( x, 1.0 / n );
}
</code></pre>
<p>mfg knockks</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1347840</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1347840</guid><dc:creator><![CDATA[knockks]]></dc:creator><pubDate>Mon, 20 Aug 2007 05:06:56 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 05:31:27 GMT]]></title><description><![CDATA[<p>Falls du <em>zum rechnen</em> runden möchtest: <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39342.html" rel="nofollow">FAQ</a></p>
<p>PS: In meinem 2. Snippet von oben fehlt ein <code>std::</code> vor <code>pow</code> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1347847</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1347847</guid><dc:creator><![CDATA[knockks]]></dc:creator><pubDate>Mon, 20 Aug 2007 05:31:27 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 08:28:28 GMT]]></title><description><![CDATA[<p>Ich finde das komisch, es gibt einen Haufen Funktionen für Hohe Mathematik, spezielle Funktionen fürs Runden(auf oder ab) aber ein einfaches automatisches Runden gibt es nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1347935</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1347935</guid><dc:creator><![CDATA[lord_fritte]]></dc:creator><pubDate>Mon, 20 Aug 2007 08:28:28 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 08:28:10 GMT]]></title><description><![CDATA[<p>Der Computer rechnet halt so genau, wie er kann - wenn dir das zu genau ist, mußt du es ihm mitteilen <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/1347936</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1347936</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 20 Aug 2007 08:28:10 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 08:29:56 GMT]]></title><description><![CDATA[<p>Ist es eigentlich möglich eigene Funktionen in der cmath.h einzutragen?</p>
<p>Was mich auch interessieren würde ist wie ein Computer die Wurzel rechnet, ich habe zwar schon ein bisschen mit Google gesucht, aber nicht wirklich was gefunden.<br />
Gibt es eine Seite wo man mal sehen kann wie eine Wurzelrechnung funktioniert?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1347940</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1347940</guid><dc:creator><![CDATA[lord_fritte]]></dc:creator><pubDate>Mon, 20 Aug 2007 08:29:56 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 08:35:55 GMT]]></title><description><![CDATA[<p>lord_fritte schrieb:</p>
<blockquote>
<p>Ich finde das komisch, es gibt einen Haufen Funktionen für Hohe Mathematik, spezielle Funktionen fürs Runden(auf oder ab) aber ein einfaches automatisches Runden gibt es nicht.</p>
</blockquote>
<p>Wie Du an der Wurzelfunktion vielleicht schon gemerkt hast, gibt es nicht für alles Funktionen, sondern gerade genug um alles nachbilden zu können. Eine x. Wurzel aus y Funktion ist nicht nötig, weil das y ^ (1/x) entspricht, und eine Potenzier-Funktion ist vorhanden.</p>
<p>Auch Rundungsfunktionen kannst Du Dir zusammenbauen: Komma verschieben, ab dem Komma runden, Komma zurückschieben. Einfache Mathematik <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="😉"
    /> - wobei ich immernoch meine, dass runden bei der Ausgabe vollkommen reicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1347942</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1347942</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Mon, 20 Aug 2007 08:35:55 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 08:35:36 GMT]]></title><description><![CDATA[<p>lord_fritte schrieb:</p>
<blockquote>
<p>Ist es eigentlich möglich eigene Funktionen in der cmath.h einzutragen?</p>
</blockquote>
<p>Theoretisch vielleicht, aber praktisch würde ich davon abraten. Notfalls kannst du dir ja einen eigenen mymath-Header mit solchen Hilfsfunktionen anlegen.<br />
(btw, der Header heißt entweder &lt;math.h&gt; oder &lt;cmath&gt; - ein &quot;cmath.h&quot; gibt es nicht)</p>
<blockquote>
<p>Was mich auch interessieren würde ist wie ein Computer die Wurzel rechnet, ich habe zwar schon ein bisschen mit Google gesucht, aber nicht wirklich was gefunden.</p>
</blockquote>
<p>Da gibt's verschiedene Ansätze, die alle zum selben Ergebnis führen: <a href="http://de.wikipedia.org/wiki/Quadratwurzel#Berechnung_von_Quadratwurzeln_aus_reellen_Zahlen" rel="nofollow">Berechnung von Wurzeln</a>. Was davon die schnellste/beste Version ist, bin ich nicht sicher.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1347943</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1347943</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 20 Aug 2007 08:35:36 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 08:35:46 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Schau dir einfach mal einen Artikel im Wikipedia über Potenzrechnung und Logarithmen an. Da findest du alles was du brauchst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1347944</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1347944</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Mon, 20 Aug 2007 08:35:46 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 08:40:02 GMT]]></title><description><![CDATA[<p>Die Wurzelrechnungen sehen alle unmöglich aus ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1347949</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1347949</guid><dc:creator><![CDATA[lord_fritte]]></dc:creator><pubDate>Mon, 20 Aug 2007 08:40:02 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 08:44:46 GMT]]></title><description><![CDATA[<p>lord_fritte schrieb:</p>
<blockquote>
<p>Die Wurzelrechnungen sehen alle unmöglich aus ^^</p>
</blockquote>
<p>Für dich vielleicht, für den Computer sind sie klar verständlich <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="😉"
    /> (aber womöglich arbeitet das System intern mit sqrt(x)==pow(x,0.5)==exp(x*ln(0.5)) (und berechnet exp() und ln() über Taylor-Reihen))</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1347955</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1347955</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 20 Aug 2007 08:44:46 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 08:50:11 GMT]]></title><description><![CDATA[<p>Du meinst sicher exp(0.5*ln(x)). <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1347967</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1347967</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Mon, 20 Aug 2007 08:50:11 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 08:52:47 GMT]]></title><description><![CDATA[<p>Oder so - das kommt davon, wenn man schneller schreibt als denkt <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="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1347969</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1347969</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 20 Aug 2007 08:52:47 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 09:02:04 GMT]]></title><description><![CDATA[<p>Ja Computer sind schon was tolles <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="😃"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1347981</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1347981</guid><dc:creator><![CDATA[lord_fritte]]></dc:creator><pubDate>Mon, 20 Aug 2007 09:02:04 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 10:41:27 GMT]]></title><description><![CDATA[<p>Nur die Funktion verstehe ich nicht:</p>
<pre><code class="language-cpp">inline double round(double Zahl, int Stellen = 0){
    Zahl *= pow( 10, Stellen);
    Zahl = floor(Zahl + 0.5);
    Zahl *= pow(10, -Stellen);
    return Zahl;
}
</code></pre>
<p>woher erkennt die Funktion wann die auf und wann sie abrunden muss?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1348072</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348072</guid><dc:creator><![CDATA[lord_fritte]]></dc:creator><pubDate>Mon, 20 Aug 2007 10:41:27 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 10:50:17 GMT]]></title><description><![CDATA[<p>lord_fritte schrieb:</p>
<blockquote>
<p>woher erkennt die Funktion wann die auf und wann sie abrunden muss?</p>
</blockquote>
<p>Gar nicht. Sie addiert 0.5 auf die letzte Stelle und schneidet dann die hinteren Stellen ab. Kommt aufs Gleiche raus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1348084</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348084</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Mon, 20 Aug 2007 10:50:17 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 10:52:14 GMT]]></title><description><![CDATA[<p>Die Funktion rundet immer ab, allerdings den Wert x+0.5 - und wenn x größer ist als n.5, landest du mit der Addition im nächsthöheren nächsthöheren Intervall und rundest effektiv auf.</p>
<pre><code>Zahl  Zahl+0.5  floor(z+0.5)
1.4   1.9       1
1.5   2.0       2
1.6   2.1       2
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1348086</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348086</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 20 Aug 2007 10:52:14 GMT</pubDate></item><item><title><![CDATA[Reply to Auf x stellen nach dem Komma runden? on Mon, 20 Aug 2007 12:39:56 GMT]]></title><description><![CDATA[<p>ja stimmt, danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1348226</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1348226</guid><dc:creator><![CDATA[lord_fritte]]></dc:creator><pubDate>Mon, 20 Aug 2007 12:39:56 GMT</pubDate></item></channel></rss>