<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Bitwise Operators used for Flagging Items</title>
	<atom:link href="http://www.robsearles.com/2009/12/02/bitwise-operators-used-for-flagging-items-part-1/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.robsearles.com/2009/12/02/bitwise-operators-used-for-flagging-items-part-1/</link>
	<description>Musing on the business of and development for "The Web"</description>
	<lastBuildDate>Fri, 03 Feb 2012 18:08:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Rob Searles &#187; Understanding Bitwise Operators (hopefully)</title>
		<link>http://www.robsearles.com/2009/12/02/bitwise-operators-used-for-flagging-items-part-1/comment-page-1/#comment-63</link>
		<dc:creator>Rob Searles &#187; Understanding Bitwise Operators (hopefully)</dc:creator>
		<pubDate>Thu, 03 Dec 2009 23:13:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.robsearles.com/?p=245#comment-63</guid>
		<description>[...] the trouble I had with bitwise operators yesterday I found some time to really sit down and get my head properly around them. Let&#8217;s dive [...]</description>
		<content:encoded><![CDATA[<p>[...] the trouble I had with bitwise operators yesterday I found some time to really sit down and get my head properly around them. Let&#8217;s dive [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob Searles</title>
		<link>http://www.robsearles.com/2009/12/02/bitwise-operators-used-for-flagging-items-part-1/comment-page-1/#comment-62</link>
		<dc:creator>Rob Searles</dc:creator>
		<pubDate>Thu, 03 Dec 2009 14:17:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.robsearles.com/?p=245#comment-62</guid>
		<description>Wow! Thanks. &lt;br&gt;&lt;br&gt;Clearly this bitwise stuff is harder than I originally thought! Good job the interwebs are full of people more brainy than me. &lt;br&gt;&lt;br&gt;I&#039;m going to have to sit down and have a long think about this stuff as my brain can&#039;t handle it right now, but I&#039;m always like that first thing in the morning.&lt;br&gt;&lt;br&gt;Thanks for your comment, and the time take to respond.</description>
		<content:encoded><![CDATA[<p>Wow! Thanks. </p>
<p>Clearly this bitwise stuff is harder than I originally thought! Good job the interwebs are full of people more brainy than me. </p>
<p>I&#39;m going to have to sit down and have a long think about this stuff as my brain can&#39;t handle it right now, but I&#39;m always like that first thing in the morning.</p>
<p>Thanks for your comment, and the time take to respond.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jespern</title>
		<link>http://www.robsearles.com/2009/12/02/bitwise-operators-used-for-flagging-items-part-1/comment-page-1/#comment-61</link>
		<dc:creator>jespern</dc:creator>
		<pubDate>Thu, 03 Dec 2009 12:47:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.robsearles.com/?p=245#comment-61</guid>
		<description>Hi Rob,&lt;br&gt;&lt;br&gt;Thanks for the mention. Unfortunately, there&#039;s something fundamentally wrong with your article, and possibly with your understanding of how this works.&lt;br&gt;&lt;br&gt;As I mention in my article, it&#039;s easy to get tricked into thinking binary OR (&#124;) is equal to numerical addition (+), alas, it is not. The same goes for numerical subtraction (-), which is, well, &amp;~ in bitwise operators, and a bit more advanced than simply doing OR and AND&#039;s.&lt;br&gt;&lt;br&gt;Consider this:&lt;br&gt;&lt;br&gt;F1 = 1&lt;&lt;1&lt;br&gt;F2 = 1&lt;&lt;2&lt;br&gt;&lt;br&gt;mask = F1 # set the F1 flag&lt;br&gt;&lt;br&gt;print mask + F1 # you get 4, which is, incorrect, F1 is already set.&lt;br&gt;print mask &#124; F1 # you get 2, which is correct, F1 is already set.&lt;br&gt;&lt;br&gt;You get the same results with subtraction:&lt;br&gt;&lt;br&gt;mask = F1 &#124; F2 # set both&lt;br&gt;print mask &amp;~ F1 # 4, which is F2, correct.&lt;br&gt;print mask - F1 # 4, also &quot;correct&quot;, but,&lt;br&gt;print (mask - F1) - F1 # 2, oops.&lt;br&gt;print (mask &amp;~ F1) &amp;~ F1 # 4, correct, bit is already unset, second time has no effect.&lt;br&gt;&lt;br&gt;You should revise your findings, as not understanding these things properly will cause significant flaws.&lt;br&gt;&lt;br&gt;Hope this helps,</description>
		<content:encoded><![CDATA[<p>Hi Rob,</p>
<p>Thanks for the mention. Unfortunately, there&#39;s something fundamentally wrong with your article, and possibly with your understanding of how this works.</p>
<p>As I mention in my article, it&#39;s easy to get tricked into thinking binary OR (|) is equal to numerical addition (+), alas, it is not. The same goes for numerical subtraction (-), which is, well, &#038;~ in bitwise operators, and a bit more advanced than simply doing OR and AND&#39;s.</p>
<p>Consider this:</p>
<p>F1 = 1&lt;&lt;1<br />F2 = 1&lt;&lt;2</p>
<p>mask = F1 # set the F1 flag</p>
<p>print mask + F1 # you get 4, which is, incorrect, F1 is already set.<br />print mask | F1 # you get 2, which is correct, F1 is already set.</p>
<p>You get the same results with subtraction:</p>
<p>mask = F1 | F2 # set both<br />print mask &#038;~ F1 # 4, which is F2, correct.<br />print mask &#8211; F1 # 4, also &#8220;correct&#8221;, but,<br />print (mask &#8211; F1) &#8211; F1 # 2, oops.<br />print (mask &#038;~ F1) &#038;~ F1 # 4, correct, bit is already unset, second time has no effect.</p>
<p>You should revise your findings, as not understanding these things properly will cause significant flaws.</p>
<p>Hope this helps,</p>
]]></content:encoded>
	</item>
</channel>
</rss>

