<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: A C++ quote and a C trivia question</title>
	<atom:link href="http://www.dubovsky.com/rantings/2006/07/09/a-c-quote-and-a-c-trivia-question/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dubovsky.com/rantings/2006/07/09/a-c-quote-and-a-c-trivia-question/</link>
	<description>Yet another web log of personal junk.</description>
	<pubDate>Tue, 06 Jan 2009 13:59:31 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: jon</title>
		<link>http://www.dubovsky.com/rantings/2006/07/09/a-c-quote-and-a-c-trivia-question/#comment-54</link>
		<dc:creator>jon</dc:creator>
		<pubDate>Sun, 09 Jul 2006 17:47:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.dubovsky.com/rantings/2006/07/09/a-c-quote-and-a-c-trivia-question/#comment-54</guid>
		<description>The short answer: the programmer was trying to do a C++-ish thing (use a boolean-value variable) but botched it: &lt;code&gt;int&lt;/code&gt; is not &lt;code&gt;bool&lt;/code&gt;.

The long answer.  The &lt;code&gt;&#038;=&lt;/code&gt; operation is a &lt;em&gt;bitwise&lt;/em&gt; or, not a &lt;em&gt;logical&lt;/em&gt; (boolean) one.  If the function returned the value 2 (or any even value), bool would be set to &lt;code&gt;2 &#038; 1&lt;/code&gt;, which is 0, erroneously indicating an error when there was none.  I believe the original programmer was thinking of &lt;code&gt;2 &#038;&#038; 1&lt;/code&gt;, which would of course work correctly.  Alas, there is no &lt;code&gt;&#038;&#038;=&lt;/code&gt; operator in C or C++.</description>
		<content:encoded><![CDATA[<p>The short answer: the programmer was trying to do a C++-ish thing (use a boolean-value variable) but botched it: <code>int</code> is not <code>bool</code>.</p>
<p>The long answer.  The <code>&#038;=</code> operation is a <em>bitwise</em> or, not a <em>logical</em> (boolean) one.  If the function returned the value 2 (or any even value), bool would be set to <code>2 &#038; 1</code>, which is 0, erroneously indicating an error when there was none.  I believe the original programmer was thinking of <code>2 &#038;&#038; 1</code>, which would of course work correctly.  Alas, there is no <code>&#038;&#038;=</code> operator in C or C++.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
