<?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[zwei float zahlen vergeleichen]]></title><description><![CDATA[<p>Hi!</p>
<pre><code class="language-cpp">void main()
{

double x = 1;
double y = 0.1;

	while(true)
	{	
		double z = 0.1;

		y += z;
		if(x == y)
		{cout&lt;&lt;&quot;geht&quot;;
			break;
		}
	}

}
</code></pre>
<p>Eigentlich sollte hier die Bedingung erfüllt sein, wenn y 1 erreicht hat, tut es aber nicht.<br />
Das Interessante ist, wenn ich y einen Startwert von 0.9 gebe, gehts.<br />
Warum ist das so?<br />
Ich verwende überhaupt VC++.</p>
<p>Vielen Dank im Vorraus1</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/123981/zwei-float-zahlen-vergeleichen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 23 Aug 2026 19:29:06 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/123981.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 22 Oct 2005 00:34:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to zwei float zahlen vergeleichen on Sat, 22 Oct 2005 00:34:38 GMT]]></title><description><![CDATA[<p>Hi!</p>
<pre><code class="language-cpp">void main()
{

double x = 1;
double y = 0.1;

	while(true)
	{	
		double z = 0.1;

		y += z;
		if(x == y)
		{cout&lt;&lt;&quot;geht&quot;;
			break;
		}
	}

}
</code></pre>
<p>Eigentlich sollte hier die Bedingung erfüllt sein, wenn y 1 erreicht hat, tut es aber nicht.<br />
Das Interessante ist, wenn ich y einen Startwert von 0.9 gebe, gehts.<br />
Warum ist das so?<br />
Ich verwende überhaupt VC++.</p>
<p>Vielen Dank im Vorraus1</p>
]]></description><link>https://www.c-plusplus.net/forum/post/898380</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/898380</guid><dc:creator><![CDATA[nightrider]]></dc:creator><pubDate>Sat, 22 Oct 2005 00:34:38 GMT</pubDate></item><item><title><![CDATA[Reply to zwei float zahlen vergeleichen on Sat, 22 Oct 2005 00:37:50 GMT]]></title><description><![CDATA[<h1>rundungsfehler.<br />
1.0/3<br />
+<br />
1.0/3<br />
+<br />
1.0/3<br />
!=<br />
1<br />
denn<br />
0.3333<br />
+<br />
0.3333<br />
+<br />
0.3333</h1>
<p>0.9999<br />
oder so ähnlich.</p>
<p>nur sind die double-zahlen nicht dezimal und 4-stellig sondern binär und vielstellig. aber es ist das gleiche problem.</p>
<p>if(fabs(x-y)&lt;0.00001)<br />
könnte man als lösung nehmen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/898381</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/898381</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Sat, 22 Oct 2005 00:37:50 GMT</pubDate></item><item><title><![CDATA[Reply to zwei float zahlen vergeleichen on Sat, 22 Oct 2005 11:21:52 GMT]]></title><description><![CDATA[<p>Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/898585</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/898585</guid><dc:creator><![CDATA[nightrider]]></dc:creator><pubDate>Sat, 22 Oct 2005 11:21:52 GMT</pubDate></item></channel></rss>