<?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[float precision angeben]]></title><description><![CDATA[<p>Hallo miteinader,<br />
ich habe eine float Variable und möchte diese mit einer Genauigkeit von von 5 Nachkommastellen in einen string schieben. Mein Quelltext sieht bisher wie folgt aus:</p>
<pre><code class="language-cpp">string s;
stringstream sstr;
sstr.precision(5);
sstr &lt;&lt; v.xPos;
s.append(sstr.str());
</code></pre>
<p>Leider funktioniert das nicht, gerade bei der 0 wird einfach nur die 0 eingetragen, statt 0.00000.</p>
<p>Was mache ich da falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/290777/float-precision-angeben</link><generator>RSS for Node</generator><lastBuildDate>Tue, 18 Aug 2026 04:43:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/290777.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 03 Aug 2011 11:34:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to float precision angeben on Wed, 03 Aug 2011 11:34:15 GMT]]></title><description><![CDATA[<p>Hallo miteinader,<br />
ich habe eine float Variable und möchte diese mit einer Genauigkeit von von 5 Nachkommastellen in einen string schieben. Mein Quelltext sieht bisher wie folgt aus:</p>
<pre><code class="language-cpp">string s;
stringstream sstr;
sstr.precision(5);
sstr &lt;&lt; v.xPos;
s.append(sstr.str());
</code></pre>
<p>Leider funktioniert das nicht, gerade bei der 0 wird einfach nur die 0 eingetragen, statt 0.00000.</p>
<p>Was mache ich da falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2101163</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2101163</guid><dc:creator><![CDATA[seux]]></dc:creator><pubDate>Wed, 03 Aug 2011 11:34:15 GMT</pubDate></item><item><title><![CDATA[Reply to float precision angeben on Wed, 03 Aug 2011 11:43:04 GMT]]></title><description><![CDATA[<p>Deine 0 ist eben auf 5 Stellen genau 0 <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="😃"
    /> . Aber guck mal hier:<br />
<a href="http://www.cplusplus.com/reference/iostream/manipulators/fixed/" rel="nofollow">http://www.cplusplus.com/reference/iostream/manipulators/fixed/</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2101169</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2101169</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 03 Aug 2011 11:43:04 GMT</pubDate></item><item><title><![CDATA[Reply to float precision angeben on Wed, 03 Aug 2011 11:45:38 GMT]]></title><description><![CDATA[<p>seux schrieb:</p>
<blockquote>
<p>Leider funktioniert das nicht, gerade bei der 0 wird einfach nur die 0 eingetragen, statt 0.00000.</p>
</blockquote>
<p>precision setzt im normalfall die maximale Genauigkeit. Und 0.0000 ist mit &quot;0&quot; genau genug angegeben, da helfen auch Nachkommastellen nicht.<br />
Bei dir fehlt noch fixed:</p>
<pre><code class="language-cpp">string s;
stringstream sstr;
sstr &lt;&lt; fixed &lt;&lt; setprecision(5) &lt;&lt; v.xPos;
s.append(sstr.str());
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2101172</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2101172</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Wed, 03 Aug 2011 11:45:38 GMT</pubDate></item><item><title><![CDATA[Reply to float precision angeben on Wed, 03 Aug 2011 12:25:47 GMT]]></title><description><![CDATA[<p>Danke, hat super hingehauen <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/2101188</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2101188</guid><dc:creator><![CDATA[seux]]></dc:creator><pubDate>Wed, 03 Aug 2011 12:25:47 GMT</pubDate></item><item><title><![CDATA[Reply to float precision angeben on Wed, 03 Aug 2011 15:05:33 GMT]]></title><description><![CDATA[<p>Ohne das &quot;fixed&quot; regelst Du über setprecision auch nicht die Nachkommastellen sondern die Zahl der Dezimalstellen <em>insgesamt</em>, die maximal verwendet werden sollen. Also: 12.345678 mit 3 Stellen sind eben &quot;12.3&quot;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2101285</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2101285</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Wed, 03 Aug 2011 15:05:33 GMT</pubDate></item></channel></rss>