<?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 f=6.28318; if(f==6.28318){...}, wird nicht erkannt]]></title><description><![CDATA[<p>Hallo,<br />
habe folgenden Code:</p>
<pre><code class="language-cpp">float f=6.28318;
 if(f==6.28318){...}
</code></pre>
<p>Der Debugger zeigt an, dass f diesen Wert hat, er springt aber nicht ind die if-Clause!</p>
<p>Was tun???<br />
Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/58996/float-f-6-28318-if-f-6-28318-wird-nicht-erkannt</link><generator>RSS for Node</generator><lastBuildDate>Tue, 02 Jun 2026 23:36:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/58996.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 17 Dec 2003 21:54:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to float f=6.28318; if(f==6.28318){...}, wird nicht erkannt on Wed, 17 Dec 2003 21:54:25 GMT]]></title><description><![CDATA[<p>Hallo,<br />
habe folgenden Code:</p>
<pre><code class="language-cpp">float f=6.28318;
 if(f==6.28318){...}
</code></pre>
<p>Der Debugger zeigt an, dass f diesen Wert hat, er springt aber nicht ind die if-Clause!</p>
<p>Was tun???<br />
Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/418646</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/418646</guid><dc:creator><![CDATA[CLoop]]></dc:creator><pubDate>Wed, 17 Dec 2003 21:54:25 GMT</pubDate></item><item><title><![CDATA[Reply to float f=6.28318; if(f==6.28318){...}, wird nicht erkannt on Wed, 17 Dec 2003 22:08:56 GMT]]></title><description><![CDATA[<p>float f=6.28318;</p>
<p>6.28318 ist eine double-Konstante, die hier in ein float reingepresst wird. Es werden einige (ziemlich viele) Bits abgeschnitten. Da diese Zahl nicht exakt im Binärsystem dargestellt werden kann, sind diese Bits wahrscheinlich nicht alle gleich 0.</p>
<p>if(f==6.28318){...}</p>
<p>Hier verhält es sich umgekehrt. f wird in double umgewandelt und mit dieser double-Konstante verglichen. Bei dieser Umwandlung werden die hinzugekommenen Bits mit 0 aufgefüllt (schätz ich mal, vielleicht auch mit etwas anderem, jedenfalls nicht mit dem, was vorher abgeschnitten wurde), so dass der Vergleich false ergibt. Wenn man die Typen angleicht, ist man das Problem los, d.h. entweder double verwenden oder 6.28318<strong>f</strong>.</p>
<p>Abgesehen davon ist es sowieso eine schlechte Idee, Gleitkommazahlen auf Gleichheit zu überprüfen, aber das war hier ausnahmsweise nicht die Fehlerursache.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/418655</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/418655</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Wed, 17 Dec 2003 22:08:56 GMT</pubDate></item><item><title><![CDATA[Reply to float f=6.28318; if(f==6.28318){...}, wird nicht erkannt on Wed, 17 Dec 2003 22:14:31 GMT]]></title><description><![CDATA[<p>Hi,<br />
schlecht von mir dokumentiert, ich habe natürlich</p>
<pre><code class="language-cpp">float f = (float) etc.
</code></pre>
<p>geschrieben.<br />
klappt aber trotzdem nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/418658</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/418658</guid><dc:creator><![CDATA[CLoop]]></dc:creator><pubDate>Wed, 17 Dec 2003 22:14:31 GMT</pubDate></item><item><title><![CDATA[Reply to float f=6.28318; if(f==6.28318){...}, wird nicht erkannt on Wed, 17 Dec 2003 22:14:48 GMT]]></title><description><![CDATA[<p>Besser auf Bereiche überprüfen, vor allem bei Rechenergebnissen. <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/418659</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/418659</guid><dc:creator><![CDATA[CrazyOwl]]></dc:creator><pubDate>Wed, 17 Dec 2003 22:14:48 GMT</pubDate></item><item><title><![CDATA[Reply to float f=6.28318; if(f==6.28318){...}, wird nicht erkannt on Wed, 17 Dec 2003 22:21:30 GMT]]></title><description><![CDATA[<p>Hi nochmal,<br />
habe jetzt das mit dem 6.28318f probiert, klappt aber auch nicht.<br />
Es würde mich mal interessieren, was mit den Bereichen gemeint ist.<br />
Vielleicht dieser &gt;&gt;-Operator?????????????????????</p>
]]></description><link>https://www.c-plusplus.net/forum/post/418665</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/418665</guid><dc:creator><![CDATA[CLoop]]></dc:creator><pubDate>Wed, 17 Dec 2003 22:21:30 GMT</pubDate></item><item><title><![CDATA[Reply to float f=6.28318; if(f==6.28318){...}, wird nicht erkannt on Wed, 17 Dec 2003 22:21:59 GMT]]></title><description><![CDATA[<p>CLoop schrieb:</p>
<blockquote>
<pre><code class="language-cpp">float f = (float) etc.
</code></pre>
<p>klappt aber trotzdem nicht.</p>
</blockquote>
<p>Na und? Das ändert ja auch überhaupt nichts an der Semantik.</p>
<p>Wenn du dagegen die Konstante in der if-Bedingung castest, klappt es.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/418666</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/418666</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Wed, 17 Dec 2003 22:21:59 GMT</pubDate></item><item><title><![CDATA[Reply to float f=6.28318; if(f==6.28318){...}, wird nicht erkannt on Wed, 17 Dec 2003 22:43:20 GMT]]></title><description><![CDATA[<p>Tut mir leid Bashar,<br />
ich habe schon</p>
<pre><code class="language-cpp">if(f==(float) 6.28318)

if(f==typecast&lt;float&gt;(6.28318))
</code></pre>
<p>probiert.<br />
Klappt alles nicht.<br />
Nur mit nem double hab ich es noch nicht probiert.<br />
ich dacht ja, es gibt ne Funktion wie compare oder so, oder ich muss im Compiler was einstellen oder irgend so etwas.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/418672</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/418672</guid><dc:creator><![CDATA[CLoop]]></dc:creator><pubDate>Wed, 17 Dec 2003 22:43:20 GMT</pubDate></item><item><title><![CDATA[Reply to float f=6.28318; if(f==6.28318){...}, wird nicht erkannt on Wed, 17 Dec 2003 22:58:38 GMT]]></title><description><![CDATA[<p>float f = 6.28318;<br />
if(f==(float) 6.28318)</p>
<p>Das muss IMHO funktionieren (tuts bei mir auch (gcc 3.2.2)). Vielleicht kann sich da ja noch jemand zu äußern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/418675</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/418675</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Wed, 17 Dec 2003 22:58:38 GMT</pubDate></item><item><title><![CDATA[Reply to float f=6.28318; if(f==6.28318){...}, wird nicht erkannt on Wed, 17 Dec 2003 23:09:35 GMT]]></title><description><![CDATA[<p>Also Bashar,<br />
bei mir klappt das nicht, sebst nicht mit &quot;Erstellen, Alles neu erstellen!&quot;<br />
Da stimmt doch irgendetwas nicht!<br />
Vielen Dank erstmal für deine Mühe!!!!!!!!!!</p>
<p>Vielleicht kann sich ja wirklich noch jemand anderes äußern!?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/418683</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/418683</guid><dc:creator><![CDATA[CLoop]]></dc:creator><pubDate>Wed, 17 Dec 2003 23:09:35 GMT</pubDate></item><item><title><![CDATA[Reply to float f=6.28318; if(f==6.28318){...}, wird nicht erkannt on Wed, 17 Dec 2003 23:35:38 GMT]]></title><description><![CDATA[<p>Meine umfangreichen Recherchen (thx @ Godot <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="😉"
    /> ) haben ergeben, dass das wohl auch im VC++6 und VC++7 klappt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/418694</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/418694</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Wed, 17 Dec 2003 23:35:38 GMT</pubDate></item><item><title><![CDATA[Reply to float f=6.28318; if(f==6.28318){...}, wird nicht erkannt on Thu, 18 Dec 2003 06:52:29 GMT]]></title><description><![CDATA[<p>Bashar schrieb:</p>
<blockquote>
<p>float f = 6.28318;<br />
if(f==(float) 6.28318)</p>
</blockquote>
<p>Also dieser von Bashar aufgeführte Ausdruck ist bei mir stets wahr, sollte also funktionieren. Ich arbeite mit VS 2003.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/418731</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/418731</guid><dc:creator><![CDATA[Plotter]]></dc:creator><pubDate>Thu, 18 Dec 2003 06:52:29 GMT</pubDate></item><item><title><![CDATA[Reply to float f=6.28318; if(f==6.28318){...}, wird nicht erkannt on Fri, 19 Dec 2003 14:21:52 GMT]]></title><description><![CDATA[<p>Also, das Problem lag wohl daran, dass ich die 6.28318 hab berechnen lassen und dass sie, obwohl sie der Debugger angezeigt hat, so nicht im Speicher standen. Das erklärt sich wohl aus den &quot;Fehlern&quot; die beim abspeichern von Floats gemacht werden. Ich werd das jetzt mal mit nem double versuchen.<br />
Habt Dank</p>
]]></description><link>https://www.c-plusplus.net/forum/post/419827</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/419827</guid><dc:creator><![CDATA[Cloop ohne Login]]></dc:creator><pubDate>Fri, 19 Dec 2003 14:21:52 GMT</pubDate></item><item><title><![CDATA[Reply to float f=6.28318; if(f==6.28318){...}, wird nicht erkannt on Fri, 19 Dec 2003 14:29:11 GMT]]></title><description><![CDATA[<p><a href="http://www.catb.org/~esr/faqs/smart-questions.html" rel="nofollow">http://www.catb.org/~esr/faqs/smart-questions.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/419833</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/419833</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Fri, 19 Dec 2003 14:29:11 GMT</pubDate></item><item><title><![CDATA[Reply to float f=6.28318; if(f==6.28318){...}, wird nicht erkannt on Fri, 19 Dec 2003 14:32:15 GMT]]></title><description><![CDATA[<p>Also mit nem double ist es ja viiiiiiiiiiiiieeel besser!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/419834</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/419834</guid><dc:creator><![CDATA[CLoop ohne Login]]></dc:creator><pubDate>Fri, 19 Dec 2003 14:32:15 GMT</pubDate></item></channel></rss>