<?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[Anzahl der Nachkommastellen in Datei schreiben?]]></title><description><![CDATA[<p>Hi.</p>
<pre><code>ofstream myfile;
double zahl;
zahl = 0.1515152356262;
myfile.open(&quot;data.txt&quot;);
myfile &lt;&lt; zahl;
myfile.close();
</code></pre>
<p>Meine Frage zu dem obigen Code wäre, ob ich irgendwie festlegen kann, wie viele Nachkommastellen von 'zahl' in die Datei geschrieben werden?<br />
Danke Euch schonmal!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/196558/anzahl-der-nachkommastellen-in-datei-schreiben</link><generator>RSS for Node</generator><lastBuildDate>Wed, 30 Sep 2026 14:15:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/196558.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 31 Oct 2007 10:08:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Anzahl der Nachkommastellen in Datei schreiben? on Wed, 31 Oct 2007 10:08:59 GMT]]></title><description><![CDATA[<p>Hi.</p>
<pre><code>ofstream myfile;
double zahl;
zahl = 0.1515152356262;
myfile.open(&quot;data.txt&quot;);
myfile &lt;&lt; zahl;
myfile.close();
</code></pre>
<p>Meine Frage zu dem obigen Code wäre, ob ich irgendwie festlegen kann, wie viele Nachkommastellen von 'zahl' in die Datei geschrieben werden?<br />
Danke Euch schonmal!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1395070</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1395070</guid><dc:creator><![CDATA[kurzeFrage]]></dc:creator><pubDate>Wed, 31 Oct 2007 10:08:59 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Nachkommastellen in Datei schreiben? on Wed, 31 Oct 2007 10:12:35 GMT]]></title><description><![CDATA[<p>Ja, kannst du: <code>myfile&lt;&lt;setprecision(anzahl)&lt;&lt;zahl;</code> (allerdings sollte dir klar sein, daß die Gleitkomma-Typen nur eine begrenzte Genauigkeit haben)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1395072</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1395072</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 31 Oct 2007 10:12:35 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Nachkommastellen in Datei schreiben? on Wed, 31 Oct 2007 12:27:10 GMT]]></title><description><![CDATA[<p>es gibt auch ein argument, dass sich setprecision wirklich auf die nachkommastellen bezieht, normal sagt es nur, wie viele Stellen es insgesamt geben kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1395166</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1395166</guid><dc:creator><![CDATA[Krux]]></dc:creator><pubDate>Wed, 31 Oct 2007 12:27:10 GMT</pubDate></item><item><title><![CDATA[Reply to Anzahl der Nachkommastellen in Datei schreiben? on Wed, 31 Oct 2007 12:35:09 GMT]]></title><description><![CDATA[<p>Krux schrieb:</p>
<blockquote>
<p>es gibt auch ein argument, dass sich setprecision wirklich auf die nachkommastellen bezieht, normal sagt es nur, wie viele Stellen es insgesamt geben kann.</p>
</blockquote>
<p>Argument ist vielleicht falsch ausgedrückt - Ausgabeflag trifft's besser (ich hoffe, ich habe deinen Satz jetzt richtig verstanden): mit &quot;myfile&lt;&lt;scientific&lt;&lt;...&quot; lässt du die Zahl im wissenschaftlichen Format (als &quot;1.51e-1&quot;) ausgeben, mit &quot;myfile&lt;&lt;fixed&lt;&lt;...&quot; im 'klassischen' Format (als &quot;0.151&quot;).<br />
(die Standardeinstellung verwendet das Format, was die kürzere Ausgabe erzeugen würde)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1395177</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1395177</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 31 Oct 2007 12:35:09 GMT</pubDate></item></channel></rss>