<?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[Typumwandlung float&#x2F;int]]></title><description><![CDATA[<p>Hallo,<br />
ich habe ein Problem mit der Typumwandlung von int und float.</p>
<p>zunächst habe ich deklariert und initialisiert:</p>
<p>int k=7, i=2;<br />
float= h;</p>
<p>h=k/7;<br />
cout &lt;&lt; h &lt;&lt; endl;</p>
<p>eigentlich würde ich nun das Ergebnis 3.0 erwarten, da h ja als float deklariert ist. stattdessen bekomme ich das Ergebnis ohne nachkommastelle: 3<br />
Liegt es vielleicht daran, dass die biblothek automatisch rundet?</p>
<p>danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/318432/typumwandlung-float-int</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Jul 2026 16:07:24 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/318432.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 12 Jul 2013 17:03:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Typumwandlung float&#x2F;int on Fri, 12 Jul 2013 17:03:10 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich habe ein Problem mit der Typumwandlung von int und float.</p>
<p>zunächst habe ich deklariert und initialisiert:</p>
<p>int k=7, i=2;<br />
float= h;</p>
<p>h=k/7;<br />
cout &lt;&lt; h &lt;&lt; endl;</p>
<p>eigentlich würde ich nun das Ergebnis 3.0 erwarten, da h ja als float deklariert ist. stattdessen bekomme ich das Ergebnis ohne nachkommastelle: 3<br />
Liegt es vielleicht daran, dass die biblothek automatisch rundet?</p>
<p>danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338484</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338484</guid><dc:creator><![CDATA[Felix4]]></dc:creator><pubDate>Fri, 12 Jul 2013 17:03:10 GMT</pubDate></item><item><title><![CDATA[Reply to Typumwandlung float&#x2F;int on Fri, 12 Jul 2013 17:05:00 GMT]]></title><description><![CDATA[<p>Welchen Compiler benutzt du, bei dem 7/7 = 3 ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338485</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338485</guid><dc:creator><![CDATA[asdfasd]]></dc:creator><pubDate>Fri, 12 Jul 2013 17:05:00 GMT</pubDate></item><item><title><![CDATA[Reply to Typumwandlung float&#x2F;int on Fri, 12 Jul 2013 17:07:09 GMT]]></title><description><![CDATA[<p>Entschuldigung, habe mich vorhin verschrieben. hier. meine frage ist weiterhin, warum ist das ergebnis nicht 3.0?</p>
<p>#include &lt;iostream&gt;<br />
#include &lt;cstdlib&gt;<br />
#include &lt;math.h&gt;<br />
#include &lt;iomanip&gt;</p>
<p>using namespace std;</p>
<p>int main ()<br />
{<br />
int i=2, k=7;<br />
float h;</p>
<p>h=k/i;<br />
cout &lt;&lt; h&lt;&lt; endl;</p>
<p>system(&quot;Pause&quot;);</p>
<p>return (0);</p>
<p>}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338488</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338488</guid><dc:creator><![CDATA[Felix4]]></dc:creator><pubDate>Fri, 12 Jul 2013 17:07:09 GMT</pubDate></item><item><title><![CDATA[Reply to Typumwandlung float&#x2F;int on Fri, 12 Jul 2013 17:16:35 GMT]]></title><description><![CDATA[<p>wenn du 3.0 dort stehen haben willst, dann musst du das hier lesen: <a href="http://www.cplusplus.com/reference/iomanip/setprecision/" rel="nofollow">http://www.cplusplus.com/reference/iomanip/setprecision/</a> bzw. <a href="http://www.cplusplus.com/reference/ios/fixed/" rel="nofollow">http://www.cplusplus.com/reference/ios/fixed/</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338492</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338492</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Fri, 12 Jul 2013 17:16:35 GMT</pubDate></item><item><title><![CDATA[Reply to Typumwandlung float&#x2F;int on Fri, 12 Jul 2013 17:30:21 GMT]]></title><description><![CDATA[<p>Felix4 schrieb:</p>
<blockquote>
<p>warum ist das ergebnis nicht 3.0?</p>
</blockquote>
<p>Weil die Leute, die die Standard-Library entwickelt/definiert haben, sich dafür entschieden haben per Default keine unnötigen Kommastellen bei der Ausgabe von floats/doubles auszugeben.</p>
<p>Natürlich gibt es diesbezüglich - wie fast überall - gute Argumente dafür und dagegen. Aber jetzt ist es halt mal so. Und du kannst ja jederzeit explizit das andere Format anfordern wenn du es brauchst - siehe Beitrag von Shade.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2338494</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2338494</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Fri, 12 Jul 2013 17:30:21 GMT</pubDate></item></channel></rss>