<?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[Überflüssiges Statement??]]></title><description><![CDATA[<p>Ich muss mich gerade durch fremden Code arbeiten und habe folgendes entdeckt:</p>
<pre><code class="language-cpp">void myClass::doSth(uint8_t value) {			
		//[hier passieren erst andere Dinge, aber value wird 100% nicht angefasst

		// value normieren (&lt;-- Originalkommentar)
		value= !!value;

                // Value wird verwendet
</code></pre>
<p>Meiner Meinung nach gibt es keinen Fall wo &quot;!!&quot; irgendwas verändern kann, oder? Ich sehe das als überflüssiges Statement an. Testweise habe ich die Zeile auskommentiert und augenscheinlich liefert das Programm dieselben Ergebnisse.</p>
<p>Bin ich jetzt blind oder was ist der Sinn von der doppelten Negotation?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/316599/überflüssiges-statement</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Jul 2026 18:35:01 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/316599.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 09 May 2013 16:41:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Überflüssiges Statement?? on Thu, 09 May 2013 16:41:40 GMT]]></title><description><![CDATA[<p>Ich muss mich gerade durch fremden Code arbeiten und habe folgendes entdeckt:</p>
<pre><code class="language-cpp">void myClass::doSth(uint8_t value) {			
		//[hier passieren erst andere Dinge, aber value wird 100% nicht angefasst

		// value normieren (&lt;-- Originalkommentar)
		value= !!value;

                // Value wird verwendet
</code></pre>
<p>Meiner Meinung nach gibt es keinen Fall wo &quot;!!&quot; irgendwas verändern kann, oder? Ich sehe das als überflüssiges Statement an. Testweise habe ich die Zeile auskommentiert und augenscheinlich liefert das Programm dieselben Ergebnisse.</p>
<p>Bin ich jetzt blind oder was ist der Sinn von der doppelten Negotation?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322229</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322229</guid><dc:creator><![CDATA[Verwirrter]]></dc:creator><pubDate>Thu, 09 May 2013 16:41:40 GMT</pubDate></item><item><title><![CDATA[Reply to Überflüssiges Statement?? on Thu, 09 May 2013 16:43:42 GMT]]></title><description><![CDATA[<p>!!5 == 1<br />
Wenn value 0 ist, dann bleibt es 0, ansonsten wird es 1.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322230</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322230</guid><dc:creator><![CDATA[nwp3]]></dc:creator><pubDate>Thu, 09 May 2013 16:43:42 GMT</pubDate></item><item><title><![CDATA[Reply to Überflüssiges Statement?? on Thu, 09 May 2013 16:47:33 GMT]]></title><description><![CDATA[<p>besten dank!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322231</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322231</guid><dc:creator><![CDATA[Verwirrter]]></dc:creator><pubDate>Thu, 09 May 2013 16:47:33 GMT</pubDate></item><item><title><![CDATA[Reply to Überflüssiges Statement?? on Thu, 09 May 2013 16:47:43 GMT]]></title><description><![CDATA[<p>nwp3 schrieb:</p>
<blockquote>
<p>!!5 == 1<br />
Wenn value 0 ist, dann bleibt es 0, ansonsten wird es 1.</p>
</blockquote>
<p>Wo liegt das der Sinn?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322232</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322232</guid><dc:creator><![CDATA[out]]></dc:creator><pubDate>Thu, 09 May 2013 16:47:43 GMT</pubDate></item><item><title><![CDATA[Reply to Überflüssiges Statement?? on Thu, 09 May 2013 16:55:22 GMT]]></title><description><![CDATA[<p>Das hängt ja nun stark davon ab, was unter &quot;// Value wird verwendet&quot; passiert. Aber mir fallen spontan 2 Anwendungsfälle ein:</p>
<p>1. Der nachfolgende Code kann nur mit 0 und 1 als Input umgehen (ist hier wohl nicht der Fall)</p>
<p>2. Um zu dokumentieren: value wird als boolesche Variable verwendet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322235</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322235</guid><dc:creator><![CDATA[SG1]]></dc:creator><pubDate>Thu, 09 May 2013 16:55:22 GMT</pubDate></item><item><title><![CDATA[Reply to Überflüssiges Statement?? on Thu, 09 May 2013 17:04:54 GMT]]></title><description><![CDATA[<p>Angenommen, es macht wirklich Sinn, dann würde ich es trotzdem nicht so machen. Sieht man ja, bringt nur Obfuscation.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322240</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322240</guid><dc:creator><![CDATA[out]]></dc:creator><pubDate>Thu, 09 May 2013 17:04:54 GMT</pubDate></item><item><title><![CDATA[Reply to Überflüssiges Statement?? on Thu, 09 May 2013 17:06:45 GMT]]></title><description><![CDATA[<p>out schrieb:</p>
<blockquote>
<p>Angenommen, es macht wirklich Sinn, dann würde ich es trotzdem nicht so machen. Sieht man ja, bringt nur Obfuscation.</p>
</blockquote>
<p>MSVC hat immer rumgewarnt bei</p>
<pre><code>value=bool(value);
</code></pre>
<p>Man würde evtl signifikante Stellen verlieren.<br />
Mit !! war die Wanung dann weg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322241</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322241</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Thu, 09 May 2013 17:06:45 GMT</pubDate></item><item><title><![CDATA[Reply to Überflüssiges Statement?? on Thu, 09 May 2013 17:09:35 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<p>MSVC hat immer rumgewarnt bei</p>
<pre><code>value=bool(value);
</code></pre>
<p>Man würde evtl signifikante Stellen verlieren.<br />
Mit !! war die Wanung dann weg.</p>
</blockquote>
<p>Stimmt, macht er noch immer: <code>warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)</code></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322243</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322243</guid><dc:creator><![CDATA[out]]></dc:creator><pubDate>Thu, 09 May 2013 17:09:35 GMT</pubDate></item><item><title><![CDATA[Reply to Überflüssiges Statement?? on Thu, 09 May 2013 17:39:00 GMT]]></title><description><![CDATA[<p>SG1 schrieb:</p>
<blockquote>
<p>Das hängt ja nun stark davon ab, was unter &quot;// Value wird verwendet&quot; passiert. Aber mir fallen spontan 2 Anwendungsfälle ein:</p>
<p>1. Der nachfolgende Code kann nur mit 0 und 1 als Input umgehen (ist hier wohl nicht der Fall)</p>
<p>2. Um zu dokumentieren: value wird als boolesche Variable verwendet.</p>
</blockquote>
<p>Nee nee es war tatsächlich Fall 1, der Code behandelt nur 0er und 1er und deswegen wird wohl eine &quot;versehentliche Übergabe&quot; von z.B. 178 in 1 umgewandelt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322250</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322250</guid><dc:creator><![CDATA[Verwirrter]]></dc:creator><pubDate>Thu, 09 May 2013 17:39:00 GMT</pubDate></item><item><title><![CDATA[Reply to Überflüssiges Statement?? on Thu, 09 May 2013 18:10:06 GMT]]></title><description><![CDATA[<p>out schrieb:</p>
<blockquote>
<p>Stimmt, macht er noch immer: <code>warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)</code></p>
</blockquote>
<p>Ja, die Warnung trotz Cast ist <a href="http://msdn.microsoft.com/en-us/library/b6801kcy(v=vs.110).aspx" rel="nofollow">Absicht</a>.</p>
<p>Verwirrter schrieb:</p>
<blockquote>
<p>deswegen wird wohl eine &quot;versehentliche Übergabe&quot; von z.B. 178 in 1 umgewandelt</p>
</blockquote>
<p>Du Funktion versteckt also Fehler bei der Übergabe. Das ist nichts Gutes.</p>
<p>Nie nie nie Logikfehler geradebiegen. Da gehört ein <code>assert(value &lt;= 1);</code> hin, alles andere ist Wahnsinn.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2322261</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2322261</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Thu, 09 May 2013 18:10:06 GMT</pubDate></item></channel></rss>