<?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[Genauigkeit einer Zahl festlegen?]]></title><description><![CDATA[<p>Habe einen Workflow, welche Allokationen mit max. Auflöung von einer ZentelSekunden enthalten soll? Die Zeitwerte werden als double angelegt!</p>
<p>wie könnte ich werte mit mehren nachkommastellen auf eine nachkomma stelle runden?</p>
<p>so:</p>
<pre><code class="language-cpp">double d= 1.4234532;

double rounded= ((double)((int)(d*10.0)))/10;
</code></pre>
<p>EDIT: Es soll IMMER aufgerundet werden ....</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/196173/genauigkeit-einer-zahl-festlegen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 07 Oct 2026 14:02:36 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/196173.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 26 Oct 2007 10:22:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Genauigkeit einer Zahl festlegen? on Fri, 26 Oct 2007 10:23:49 GMT]]></title><description><![CDATA[<p>Habe einen Workflow, welche Allokationen mit max. Auflöung von einer ZentelSekunden enthalten soll? Die Zeitwerte werden als double angelegt!</p>
<p>wie könnte ich werte mit mehren nachkommastellen auf eine nachkomma stelle runden?</p>
<p>so:</p>
<pre><code class="language-cpp">double d= 1.4234532;

double rounded= ((double)((int)(d*10.0)))/10;
</code></pre>
<p>EDIT: Es soll IMMER aufgerundet werden ....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1392389</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1392389</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Fri, 26 Oct 2007 10:23:49 GMT</pubDate></item><item><title><![CDATA[Reply to Genauigkeit einer Zahl festlegen? on Fri, 26 Oct 2007 10:29:14 GMT]]></title><description><![CDATA[<p><a href="http://man.cx/floor()" rel="nofollow">man: floor()</a> und <a href="http://man.cx/ceil()" rel="nofollow">man: ceil()</a> dürften für dich geeignet sein <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="😉"
    /> (zur Not mußt du den Wert dafür noch geeignet skalieren)</p>
<pre><code class="language-cpp">double round_up(double val,int precision)
{
  double skal = pow(10,precision);
  return ceil(val*skal)/skal;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1392393</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1392393</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 26 Oct 2007 10:29:14 GMT</pubDate></item><item><title><![CDATA[Reply to Genauigkeit einer Zahl festlegen? on Fri, 26 Oct 2007 11:42:19 GMT]]></title><description><![CDATA[<p>BorisDieKlinge schrieb:</p>
<blockquote>
<p>Habe einen Workflow, welche Allokationen mit max. Auflöung von einer ZentelSekunden enthalten soll?</p>
</blockquote>
<p>Ist das eine Frage?</p>
<blockquote>
<p>Die Zeitwerte werden als double angelegt!</p>
<p>wie könnte ich werte mit mehren nachkommastellen auf eine nachkomma stelle runden?</p>
<p>so:</p>
<pre><code class="language-cpp">double d= 1.4234532;

double rounded= ((double)((int)(d*10.0)))/10;
</code></pre>
<p>EDIT: Es soll IMMER aufgerundet werden ....</p>
</blockquote>
<p>Stellt sich die Frage, warum du runden willst. Wenns nur um die Anzeige geht =&gt; setprecision und andere Streammodifikatoren. Wenn du - zu welchem zweck auch immer - intern runden willst, siehe ceil() (CStolls Bsp)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1392442</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1392442</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Fri, 26 Oct 2007 11:42:19 GMT</pubDate></item><item><title><![CDATA[Reply to Genauigkeit einer Zahl festlegen? on Fri, 26 Oct 2007 11:57:59 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">double round_up(double value, std::size_t precision)
{
    const double skal(std::pow(10.0, static_cast&lt;double&gt;(precision)));
    return std::ceil(val * skal) / skal;
}
</code></pre>
<p>sonnst könnte es dir passieren, dass er nicht weiß, welche std::pow er nutzen soll ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1392453</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1392453</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Fri, 26 Oct 2007 11:57:59 GMT</pubDate></item><item><title><![CDATA[Reply to Genauigkeit einer Zahl festlegen? on Fri, 26 Oct 2007 17:47:25 GMT]]></title><description><![CDATA[<p>Ich möchte nur nochmal darauf hinweisen dass double und float sich nicht genauen Darstellung von Dezimalzahlen eignen, und man daher mit double/float auch nicht genau mit &quot;auf eine Dezimalstelle gerundeten&quot; Zahlen rechnen kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1392695</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1392695</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Fri, 26 Oct 2007 17:47:25 GMT</pubDate></item><item><title><![CDATA[Reply to Genauigkeit einer Zahl festlegen? on Sun, 04 Nov 2007 09:47:46 GMT]]></title><description><![CDATA[<p>Double und float sind intern sehr genau. Das Runden ist Angelegenheit der<br />
Ausgabe - siehe vorherige Anworten. Vielleicht verwendest Du effizienter<br />
long integer oder integer, dann gibt es keine Probleme mit irgendwelchen<br />
Rundungen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1397344</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1397344</guid><dc:creator><![CDATA[berniebutt]]></dc:creator><pubDate>Sun, 04 Nov 2007 09:47:46 GMT</pubDate></item><item><title><![CDATA[Reply to Genauigkeit einer Zahl festlegen? on Tue, 22 Jan 2008 11:12:20 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich hab auch mal kurz eine frage zum thema runden und wollte jetzt nicht extra einen neuen thread.<br />
mein problem ist ich habe eine variable double zahl z.b. 90.1765 die soll dann immer auf eine stelle hinter dem komma gerundet werden, also 90.2.<br />
kennt da jm. eine gute kurze lösung?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1441188</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1441188</guid><dc:creator><![CDATA[vonder]]></dc:creator><pubDate>Tue, 22 Jan 2008 11:12:20 GMT</pubDate></item><item><title><![CDATA[Reply to Genauigkeit einer Zahl festlegen? on Tue, 22 Jan 2008 11:19:27 GMT]]></title><description><![CDATA[<p>Siehe (D)Evils Post und rufe die Methode entsprechend auf.</p>
<p>Wenn kaufmännisch gerundet werden soll, statt ceil floor nehmen und vorher 0.5 draufrechnen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1441193</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1441193</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Tue, 22 Jan 2008 11:19:27 GMT</pubDate></item><item><title><![CDATA[Reply to Genauigkeit einer Zahl festlegen? on Tue, 22 Jan 2008 11:27:40 GMT]]></title><description><![CDATA[<p>gibts keine elegantere lösung?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1441204</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1441204</guid><dc:creator><![CDATA[vonder]]></dc:creator><pubDate>Tue, 22 Jan 2008 11:27:40 GMT</pubDate></item><item><title><![CDATA[Reply to Genauigkeit einer Zahl festlegen? on Tue, 22 Jan 2008 11:50:48 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">ceil(x*10.0)/10.0
</code></pre>
<p>Kürzer ist es vielleicht...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1441222</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1441222</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Tue, 22 Jan 2008 11:50:48 GMT</pubDate></item><item><title><![CDATA[Reply to Genauigkeit einer Zahl festlegen? on Wed, 23 Jan 2008 15:38:25 GMT]]></title><description><![CDATA[<p>noch eine frage. wie bekomm ich es hin, wenn mein ergebnis 1 ist und ich möchte 1.0000 ausgeben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1442097</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1442097</guid><dc:creator><![CDATA[vonder]]></dc:creator><pubDate>Wed, 23 Jan 2008 15:38:25 GMT</pubDate></item><item><title><![CDATA[Reply to Genauigkeit einer Zahl festlegen? on Wed, 23 Jan 2008 15:46:11 GMT]]></title><description><![CDATA[<p><a href="http://www.willemer.de/informatik/cpp/iostream.htm" rel="nofollow">http://www.willemer.de/informatik/cpp/iostream.htm</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1442107</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1442107</guid><dc:creator><![CDATA[langeweile]]></dc:creator><pubDate>Wed, 23 Jan 2008 15:46:11 GMT</pubDate></item></channel></rss>