<?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[Ausgabeformatierungsproblem]]></title><description><![CDATA[<p>Grüße euch,</p>
<p>ich habe folgendes Problem.</p>
<p>Ich gebe über cout lauter double Werte aus. Bis jetzt sieht die Ausgabe zB so aus:</p>
<p>1.2<br />
4<br />
3.35<br />
19</p>
<p>Das Problem ist dass ich die Ausgabe gerne wie folgt hätte:</p>
<p>1.2<br />
4.0<br />
3.35<br />
19.0</p>
<p>Ich habs scho geschafft dass ich Ausgaben erzeuge mit einer fixen Anzahl von Nachkommastellen, aber ich muss es leider so mache. Also ganze Zahlen mit .0 und alle anderen Zahlen mit der jeweiligen Anzahl von Nachkommastellen.</p>
<p>Ich hoffe mir kann da jemand helfen??</p>
<p>MfG<br />
Conrad</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/147985/ausgabeformatierungsproblem</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 11:57:47 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/147985.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 22 May 2006 12:16:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Ausgabeformatierungsproblem on Mon, 22 May 2006 12:16:39 GMT]]></title><description><![CDATA[<p>Grüße euch,</p>
<p>ich habe folgendes Problem.</p>
<p>Ich gebe über cout lauter double Werte aus. Bis jetzt sieht die Ausgabe zB so aus:</p>
<p>1.2<br />
4<br />
3.35<br />
19</p>
<p>Das Problem ist dass ich die Ausgabe gerne wie folgt hätte:</p>
<p>1.2<br />
4.0<br />
3.35<br />
19.0</p>
<p>Ich habs scho geschafft dass ich Ausgaben erzeuge mit einer fixen Anzahl von Nachkommastellen, aber ich muss es leider so mache. Also ganze Zahlen mit .0 und alle anderen Zahlen mit der jeweiligen Anzahl von Nachkommastellen.</p>
<p>Ich hoffe mir kann da jemand helfen??</p>
<p>MfG<br />
Conrad</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1062732</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1062732</guid><dc:creator><![CDATA[wacky]]></dc:creator><pubDate>Mon, 22 May 2006 12:16:39 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabeformatierungsproblem on Mon, 22 May 2006 12:18:34 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">cout&lt;&lt;fixed&lt;&lt;showpoint&lt;&lt;setprecision(2);
</code></pre>
<p>^^ danach werden Gleitkommazahlen mit zwei Stellen nach dem Komma angegeben (notfalls mit 0 aufgefüllt).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1062735</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1062735</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 22 May 2006 12:18:34 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabeformatierungsproblem on Mon, 22 May 2006 12:28:32 GMT]]></title><description><![CDATA[<p>Naja, das will ich ja ned, das hätte ich eh scho hinbekommen.</p>
<p>Dann wäre die Ausgabe ja:</p>
<p>1.20<br />
4.00<br />
3.35<br />
19.00</p>
<p>Es soll aber immer so aussehen: (andere Beispiel damit man es besser sieht)</p>
<p>Ich gebe ein:</p>
<p>1<br />
2<br />
1.1<br />
2.3423</p>
<p>Ausgabe soll sein:</p>
<p>1.0<br />
2.0<br />
1.1<br />
2.3423</p>
<p>Und das check i ned wie ich das machen soll</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1062746</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1062746</guid><dc:creator><![CDATA[wacky]]></dc:creator><pubDate>Mon, 22 May 2006 12:28:32 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabeformatierungsproblem on Mon, 22 May 2006 12:42:55 GMT]]></title><description><![CDATA[<p>Dann versuch halt mal</p>
<pre><code class="language-cpp">cout&lt;&lt;fixed&lt;&lt;showpoint&lt;&lt;setprecision(1);
</code></pre>
<p>EDIT: Ups, sorry hab nicht gesehen das es auch mehrere Nachkommastellen sein können.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1062758</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1062758</guid><dc:creator><![CDATA[EEK]]></dc:creator><pubDate>Mon, 22 May 2006 12:42:55 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabeformatierungsproblem on Mon, 22 May 2006 12:44:30 GMT]]></title><description><![CDATA[<p>Das geht ja auch ned, weil mir wenn ich mehr als 1 Nachkommastelle habe, diese beim Ausgeben weggeschnitten werden.</p>
<p>Also aus 23.34323 wird 23.3</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1062762</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1062762</guid><dc:creator><![CDATA[wacky]]></dc:creator><pubDate>Mon, 22 May 2006 12:44:30 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabeformatierungsproblem on Mon, 22 May 2006 13:28:36 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Du könntest die Nachkommastellen abfragen und die Präzision dementsprechend setzen.</p>
<p>chrische</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1062778</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1062778</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Mon, 22 May 2006 13:28:36 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabeformatierungsproblem on Mon, 22 May 2006 13:26:59 GMT]]></title><description><![CDATA[<p>Die Idee klingt gut, nur hab ich ehrlich gesagt keine Ahnung wie ich die Nachkommastellenanzahl abfrage <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>Wäre toll wenn mir das auch noch jemand erklären könnte...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1062785</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1062785</guid><dc:creator><![CDATA[wacky]]></dc:creator><pubDate>Mon, 22 May 2006 13:26:59 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabeformatierungsproblem on Mon, 22 May 2006 13:38:01 GMT]]></title><description><![CDATA[<p>also eine ganz einfache methode wäre die</p>
<pre><code class="language-cpp">float a;
cin&gt;&gt;a;
cout&lt;&lt;fixed&lt;&lt;showpoint&lt;&lt;setprecision(1);

if(a&lt;0.1)
 cout&lt;&lt;fixed&lt;&lt;showpoint&lt;&lt;setprecision(2);
if(a&lt;0.01)
 cout&lt;&lt;fixed&lt;&lt;showpoint&lt;&lt;setprecision(3);
if(a&lt;0.001)
 cout&lt;&lt;fixed&lt;&lt;showpoint&lt;&lt;setprecision(4);

cout&lt;&lt;a&lt;&lt;endl;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1062796</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1062796</guid><dc:creator><![CDATA[ser1al]]></dc:creator><pubDate>Mon, 22 May 2006 13:38:01 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabeformatierungsproblem on Mon, 22 May 2006 13:53:01 GMT]]></title><description><![CDATA[<p>Also das versteh ich jetzt ned.</p>
<p>Das funktioniert ja nur wenn ich zahlen eingebe die mit 0. beginnen.</p>
<p>Wenn ich 2.3343 eingeben würde, würde dann schätz ich mal 2.3 raus kommen, oder nicht?</p>
<p>Also wenn es nicht so ist, dann wärs toll wenn mir jemand erklärt warum das funktionert. Weil das überfordert dann meine c++ Kenntnisse...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1062815</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1062815</guid><dc:creator><![CDATA[wacky]]></dc:creator><pubDate>Mon, 22 May 2006 13:53:01 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabeformatierungsproblem on Mon, 22 May 2006 13:59:58 GMT]]></title><description><![CDATA[<p>ne, so gehts nicht...</p>
<p>du musst das dann so abfragen:</p>
<p>if(a-floor(a)) &lt; 0.001f)<br />
setprecision...</p>
<p>edit: wobei das auch noch nciht reicht... <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/1062825</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1062825</guid><dc:creator><![CDATA[Maxi]]></dc:creator><pubDate>Mon, 22 May 2006 13:59:58 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabeformatierungsproblem on Mon, 22 May 2006 14:11:23 GMT]]></title><description><![CDATA[<p>Lass dir die Ausgabe doch einfach in einen StringStream eintragen, anstatt direkt auf cout und schaue einfach nach, ob ein &quot;.&quot; drin vorkommt. Wenn nicht dann einfach &quot;.0&quot; anhängen und den Text ausgeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1062836</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1062836</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Mon, 22 May 2006 14:11:23 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabeformatierungsproblem on Mon, 22 May 2006 14:33:19 GMT]]></title><description><![CDATA[<p>OK, ich habe mir jetzt folgendes überlegt.</p>
<p>Es würde genügen wenn ich herausfinden könnte ob ein double eine Ganzzahl beinhaltet. Und wenn das der Fall ist mache ich ein setprecision(1) und sonst gebe ich es ganz normal aus.</p>
<p>Also ich hätte es ja wie folgt überprüft</p>
<p>if(a = (long)a)</p>
<p>Das funktioniert aber leider auch nur bis zu einer bestimmten Größe des double Werts.</p>
<p>Weiß irgendwer eine Lösung die das immer schafft?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1062857</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1062857</guid><dc:creator><![CDATA[wacky]]></dc:creator><pubDate>Mon, 22 May 2006 14:33:19 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabeformatierungsproblem on Mon, 22 May 2006 14:39:24 GMT]]></title><description><![CDATA[<p>Wenn dir mein obiger Vorschlag nicht zusagt, dann nimm doch</p>
<pre><code class="language-cpp">if(a == floor(a))
</code></pre>
<p>wobei du besser noch einen &quot;Epsilon&quot;-Vergleich nehmen solltest, also wie Maxi schon geschrieben hat:</p>
<pre><code class="language-cpp">if(a-floor(a)) &lt; 1e-20)
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1062861</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1062861</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Mon, 22 May 2006 14:39:24 GMT</pubDate></item><item><title><![CDATA[Reply to Ausgabeformatierungsproblem on Mon, 22 May 2006 14:43:06 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/9348">@TH</a></p>
<p>Achso, ich habe deine Antwort gar nicht bemerkt, weil die auf der 2. Seite war. Ich werd das gleich mal ausprobieren ob das den gewünschten Effekt hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1062864</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1062864</guid><dc:creator><![CDATA[wacky]]></dc:creator><pubDate>Mon, 22 May 2006 14:43:06 GMT</pubDate></item></channel></rss>