<?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[Mein Computer rechnet falsch &#x2F;&#x2F; 1.2 - 1 != 0.2]]></title><description><![CDATA[<p>Moin,<br />
erstmal vorweg ich weiß nicht ob es eine MFC frage ist *hoff*.</p>
<p>Also nun zu meinem Problem. Ich Reche ganz leichte Sachen mit VS7.0. Und bekomme immer falsche Ergebnise, obwohl ich meiner Meinung nach richtige Datentypen verwende. Ist Microsoft doof oder ich?</p>
<p>Was mach ich falsch, bei den folgenen Gleichung bekomme ich immer was falsches raus:</p>
<p>1.2f - 1 = 0.20000004768371582<br />
(float)1.2 - (int)1 = 0.20000004768371582<br />
(double)1.2 - (int)1 = 0.19999999999999996<br />
(double)1.2 - (int)1 = 0.19999999999999996<br />
1.2 - 1 = 0.19999999999999996<br />
(long double)1.2 - (long double)1 = 0.19999999999999996</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/6264/mein-computer-rechnet-falsch-1-2-1-0-2</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 06:35:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/6264.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 20 Jun 2003 06:13:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Mein Computer rechnet falsch &#x2F;&#x2F; 1.2 - 1 != 0.2 on Fri, 20 Jun 2003 06:13:00 GMT]]></title><description><![CDATA[<p>Moin,<br />
erstmal vorweg ich weiß nicht ob es eine MFC frage ist *hoff*.</p>
<p>Also nun zu meinem Problem. Ich Reche ganz leichte Sachen mit VS7.0. Und bekomme immer falsche Ergebnise, obwohl ich meiner Meinung nach richtige Datentypen verwende. Ist Microsoft doof oder ich?</p>
<p>Was mach ich falsch, bei den folgenen Gleichung bekomme ich immer was falsches raus:</p>
<p>1.2f - 1 = 0.20000004768371582<br />
(float)1.2 - (int)1 = 0.20000004768371582<br />
(double)1.2 - (int)1 = 0.19999999999999996<br />
(double)1.2 - (int)1 = 0.19999999999999996<br />
1.2 - 1 = 0.19999999999999996<br />
(long double)1.2 - (long double)1 = 0.19999999999999996</p>
]]></description><link>https://www.c-plusplus.net/forum/post/30411</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/30411</guid><dc:creator><![CDATA[Kay]]></dc:creator><pubDate>Fri, 20 Jun 2003 06:13:00 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Computer rechnet falsch &#x2F;&#x2F; 1.2 - 1 != 0.2 on Fri, 20 Jun 2003 06:20:00 GMT]]></title><description><![CDATA[<p>Das liegt am Typ double.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/30412</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/30412</guid><dc:creator><![CDATA[HELP]]></dc:creator><pubDate>Fri, 20 Jun 2003 06:20:00 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Computer rechnet falsch &#x2F;&#x2F; 1.2 - 1 != 0.2 on Fri, 20 Jun 2003 06:29:00 GMT]]></title><description><![CDATA[<p>Ahh Haa und wie mach ich es richtig? Ohne double? Also mit Float Rechnet er auch bei mir falsch:</p>
<p>(float)((float)1.2 - (float)1) 0.20000005 float</p>
]]></description><link>https://www.c-plusplus.net/forum/post/30413</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/30413</guid><dc:creator><![CDATA[Kay]]></dc:creator><pubDate>Fri, 20 Jun 2003 06:29:00 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Computer rechnet falsch &#x2F;&#x2F; 1.2 - 1 != 0.2 on Fri, 20 Jun 2003 06:30:00 GMT]]></title><description><![CDATA[<p>Ups meinte:<br />
(float)((float)1.2 - (float)1) = 0.20000005</p>
]]></description><link>https://www.c-plusplus.net/forum/post/30414</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/30414</guid><dc:creator><![CDATA[Kay]]></dc:creator><pubDate>Fri, 20 Jun 2003 06:30:00 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Computer rechnet falsch &#x2F;&#x2F; 1.2 - 1 != 0.2 on Fri, 20 Jun 2003 07:16:00 GMT]]></title><description><![CDATA[<p>Hatte mal das gleiche Problem. Das hängt wohl mit der Berechnung der Datentypen, wenn du rundest, stimmt es meistens wieder.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/30415</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/30415</guid><dc:creator><![CDATA[HELP]]></dc:creator><pubDate>Fri, 20 Jun 2003 07:16:00 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Computer rechnet falsch &#x2F;&#x2F; 1.2 - 1 != 0.2 on Fri, 20 Jun 2003 07:47:00 GMT]]></title><description><![CDATA[<p>*will nicht glauben*<br />
Also ich kann mit</p>
<p>float(Signed):<br />
Min 1.17549e-38<br />
Max 3.40282e+38<br />
Kommastellen: 6</p>
<p>double(Signed):<br />
Min 2.22507385851e-308<br />
Max 1.79769313486e+308<br />
Kommastellen: 15</p>
<p>darstellen. Aber das alles nützt doch nix, wenn ich damit Rechnen will, da ich runen muß/soll!? Es gibt doch auch Mathematik Programme mit was für einen Datentyp rechnen die denn? Haben die sich extra eigene Datentypen geschreiben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/30416</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/30416</guid><dc:creator><![CDATA[Kay]]></dc:creator><pubDate>Fri, 20 Jun 2003 07:47:00 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Computer rechnet falsch &#x2F;&#x2F; 1.2 - 1 != 0.2 on Fri, 20 Jun 2003 08:01:00 GMT]]></title><description><![CDATA[<p>Wo ist das Problem <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<pre><code class="language-cpp">double a=1.2, b=1.0;
printf( &quot;%.15lf - %.15lf = %.15lf\n&quot;, a, b, a-b);
// Ausgabe:
// 1.200000000000000-1.000000000000000=0.2000000000000000;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/30417</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/30417</guid><dc:creator><![CDATA[RenéG]]></dc:creator><pubDate>Fri, 20 Jun 2003 08:01:00 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Computer rechnet falsch &#x2F;&#x2F; 1.2 - 1 != 0.2 on Fri, 20 Jun 2003 08:59:00 GMT]]></title><description><![CDATA[<p>Hast du deinen Compi übertaktet? Dann kann er auch falsch rechnen...</p>
<p>so long</p>
]]></description><link>https://www.c-plusplus.net/forum/post/30418</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/30418</guid><dc:creator><![CDATA[Schwupi]]></dc:creator><pubDate>Fri, 20 Jun 2003 08:59:00 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Computer rechnet falsch &#x2F;&#x2F; 1.2 - 1 != 0.2 on Fri, 20 Jun 2003 09:04:00 GMT]]></title><description><![CDATA[<blockquote>
<p>Hast du deinen Compi übertaktet? Dann kann er auch falsch rechnen...</p>
</blockquote>
<p>Wäre dann nicht das Betriebssystem eher abgestürzt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/30419</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/30419</guid><dc:creator><![CDATA[RenéG]]></dc:creator><pubDate>Fri, 20 Jun 2003 09:04:00 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Computer rechnet falsch &#x2F;&#x2F; 1.2 - 1 != 0.2 on Fri, 20 Jun 2003 09:18:00 GMT]]></title><description><![CDATA[<p>Nicht unbedingt, da gibts doch so ein Proggie, da kann man einen Test machen. Bei der kleinsten Abweichung eines Ergebnisses schlägt es Alarm.<br />
Das nimmt man, um zu testen, ob der Compi trotz Übertaktung) noch genau rechnet. Der rechnet ja nicht nur falsch, wenn er zu heiß ist, sondern auch, wenn die Spannung zu hoch ist. Da kannst du auch mit der WaKü kühlen, trotzdem falsche Ergebnisse.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/30420</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/30420</guid><dc:creator><![CDATA[Schwupi]]></dc:creator><pubDate>Fri, 20 Jun 2003 09:18:00 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Computer rechnet falsch &#x2F;&#x2F; 1.2 - 1 != 0.2 on Fri, 20 Jun 2003 09:34:00 GMT]]></title><description><![CDATA[<p>Schwupi hat unrecht.</p>
<p>es ist schlicht der typ double, der gar nicht 308 genaue stellen hat, sondern viel weniger.<br />
er stellt die zahlen eher da als b*2^m.<br />
b nennt man basis und m nennt man mantisse.<br />
so, wie eir es auch gewohnt sind, wenn wie 3,18*10^134 sagen. und mit rechenfehlern wie 3,18*10^134 + 1.23*10^23 == 3,18*10^134.<br />
dazu kommt noch unterstützend, daß 0.2 im binärsystem nicht glatt aufgeht, und dort ein periodischer dezimalbruch steht (und hinten sicher stellen abgeschnippelt erden).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/30421</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/30421</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Fri, 20 Jun 2003 09:34:00 GMT</pubDate></item><item><title><![CDATA[Reply to Mein Computer rechnet falsch &#x2F;&#x2F; 1.2 - 1 != 0.2 on Fri, 20 Jun 2003 11:56:00 GMT]]></title><description><![CDATA[<p>Ich wollte ja auch nicht recht haben, sonder habe nur vermutet, ob es auch daran liegen kann.</p>
<p>Aber deine Antwort erstaunt mich, hätte ich nicht gewusst. Na ja, wieder was gelernt...</p>
<p>so long</p>
]]></description><link>https://www.c-plusplus.net/forum/post/30422</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/30422</guid><dc:creator><![CDATA[Schwupi]]></dc:creator><pubDate>Fri, 20 Jun 2003 11:56:00 GMT</pubDate></item></channel></rss>