<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: A Quick Bitmask HOWTO for Programmers</title>
	<link>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Mon, 13 Oct 2008 14:19:04 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Jordan</title>
		<link>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-19965</link>
		<dc:creator>Jordan</dc:creator>
		<pubDate>Tue, 20 Nov 2007 21:27:09 +0000</pubDate>
		<guid>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-19965</guid>
		<description>Hello, I stumbled upon this looking for a refresher (I saw this once before in a class and this would be my first time applying it).

I may be confused but I think there may be a problem with your laymen algorithm:

Our cart can have the following items in it (with the values provided in your example.)
Lets assume only an orange and apple is in the cart

Sum = 6
sum mod 4  0 (an apple is in the cart)
sum mod 2 = 0 (an orange is NOT in the cart)  -&#62; ERROR

But what if we only had an apple in the cart

Is this not working because we are dealing with integers in the example? (I was under the impression that the compiler and the speed of bitshifting within a processor would take care of the conversion).

If a bitmask can be applied with integers, I suspect I need to apply more than a mod to obtain the result.  Can you tell me what I'm missing?

Thanks.

PS: Sorry for writing this about 3 years late  ; &#62;)</description>
		<content:encoded><![CDATA[<p>Hello, I stumbled upon this looking for a refresher (I saw this once before in a class and this would be my first time applying it).</p>
<p>I may be confused but I think there may be a problem with your laymen algorithm:</p>
<p>Our cart can have the following items in it (with the values provided in your example.)<br />
Lets assume only an orange and apple is in the cart</p>
<p>Sum = 6<br />
sum mod 4  0 (an apple is in the cart)<br />
sum mod 2 = 0 (an orange is NOT in the cart)  -&gt; ERROR</p>
<p>But what if we only had an apple in the cart</p>
<p>Is this not working because we are dealing with integers in the example? (I was under the impression that the compiler and the speed of bitshifting within a processor would take care of the conversion).</p>
<p>If a bitmask can be applied with integers, I suspect I need to apply more than a mod to obtain the result.  Can you tell me what I&#8217;m missing?</p>
<p>Thanks.</p>
<p>PS: Sorry for writing this about 3 years late  ; &gt;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-4651</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Fri, 16 Jun 2006 04:32:42 +0000</pubDate>
		<guid>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-4651</guid>
		<description>Im a junior comp sci student, and i had never heard of bitmask till today. It came about at my job @ IT when i asked one of our "geniuses" for a tutorial on something. Just like it was mentioned in a previous post, the best in the field are the most helpful and humble. Ive learned that insecure people walking around telling illiterates that they are hackers and programmers have John's attitude and end up failing because of it. Team work is the best learning environment in my opinion. It is impossible to know everything.</description>
		<content:encoded><![CDATA[<p>Im a junior comp sci student, and i had never heard of bitmask till today. It came about at my job @ IT when i asked one of our &#8220;geniuses&#8221; for a tutorial on something. Just like it was mentioned in a previous post, the best in the field are the most helpful and humble. Ive learned that insecure people walking around telling illiterates that they are hackers and programmers have John&#8217;s attitude and end up failing because of it. Team work is the best learning environment in my opinion. It is impossible to know everything.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-4142</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Fri, 09 Jun 2006 21:15:27 +0000</pubDate>
		<guid>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-4142</guid>
		<description>I think John has a point, although he is a moron. A true programmer understands the underlying concepts, this should be learnt when you first start programming. Calling yourself (in the literal sense, not the author) a professional when you don't know the basic principles is like calling yourself a mechanic and not knowing that cars use combustion engines but happily repairing engines because they have using parts. I wouldn't want that mechanic to work on my car. Note that in my contrived analogy the mechanic does not need to know thermodynamics, simply how in general it works, likewise a programmer needn't be expected to use microcode or assembler.</description>
		<content:encoded><![CDATA[<p>I think John has a point, although he is a moron. A true programmer understands the underlying concepts, this should be learnt when you first start programming. Calling yourself (in the literal sense, not the author) a professional when you don&#8217;t know the basic principles is like calling yourself a mechanic and not knowing that cars use combustion engines but happily repairing engines because they have using parts. I wouldn&#8217;t want that mechanic to work on my car. Note that in my contrived analogy the mechanic does not need to know thermodynamics, simply how in general it works, likewise a programmer needn&#8217;t be expected to use microcode or assembler.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-3515</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Tue, 23 May 2006 19:38:15 +0000</pubDate>
		<guid>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-3515</guid>
		<description>Thanks! I have been tasked with working with a db that uses bit masks and almost drew a blank. I have completely forgotten how it all came together. This article totally recalled the bit thought pattern for me!

Thank again!</description>
		<content:encoded><![CDATA[<p>Thanks! I have been tasked with working with a db that uses bit masks and almost drew a blank. I have completely forgotten how it all came together. This article totally recalled the bit thought pattern for me!</p>
<p>Thank again!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonas</title>
		<link>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-3333</link>
		<dc:creator>Jonas</dc:creator>
		<pubDate>Sun, 14 May 2006 08:45:21 +0000</pubDate>
		<guid>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-3333</guid>
		<description>That john must be totally retarded.

How stupid can a person be?</description>
		<content:encoded><![CDATA[<p>That john must be totally retarded.</p>
<p>How stupid can a person be?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee</title>
		<link>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-2902</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Thu, 20 Apr 2006 14:35:20 +0000</pubDate>
		<guid>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-2902</guid>
		<description>Thank you. Very nice tutorial and great responses! Except for the one guy who should die and clear out the gene pool a bit....</description>
		<content:encoded><![CDATA[<p>Thank you. Very nice tutorial and great responses! Except for the one guy who should die and clear out the gene pool a bit&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-2415</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Mon, 04 Apr 2005 22:29:59 +0000</pubDate>
		<guid>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-2415</guid>
		<description>One thing I will add, the main problem with these (and I dont like it much) is that you can run out of bits/flags you can assign quickly.

For example, a 32 bit number means you can only have up to 32 different permission flags, or items in your cart etc.

You wouldnt use a bitmask to handle what items a user has in their shopping cart, as there would be 1000's of items (and to have 1000s of items supported, you would need a 1000bit+ bitmask to handle each item).</description>
		<content:encoded><![CDATA[<p>One thing I will add, the main problem with these (and I dont like it much) is that you can run out of bits/flags you can assign quickly.</p>
<p>For example, a 32 bit number means you can only have up to 32 different permission flags, or items in your cart etc.</p>
<p>You wouldnt use a bitmask to handle what items a user has in their shopping cart, as there would be 1000&#8217;s of items (and to have 1000s of items supported, you would need a 1000bit+ bitmask to handle each item).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-2414</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Mon, 04 Apr 2005 22:28:32 +0000</pubDate>
		<guid>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-2414</guid>
		<description>You need to use bitmasks.

If you want more options, use a larger bit mask field (eg 0000000 instead of just 0000).</description>
		<content:encoded><![CDATA[<p>You need to use bitmasks.</p>
<p>If you want more options, use a larger bit mask field (eg 0000000 instead of just 0000).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sqlgeek</title>
		<link>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-2413</link>
		<dc:creator>sqlgeek</dc:creator>
		<pubDate>Sat, 19 Mar 2005 00:30:37 +0000</pubDate>
		<guid>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-2413</guid>
		<description>so i still have questions in regards to this...

Scenario:

91 &#124; 92 = 95 (1011011 &#124; 1011100 = 1011111)

Test:
95 &#038; 91 = 91 CORRECT
95 &#038; 92 = 92 CORRECT
95 &#038; 93 = 93 ??
95 &#038; 5 = 5 ??
95 &#038; 6 = 4 ??

I recognize that powers of 2 should be used to avoid just this complication.  However I have a dev manager that is convinced that it can be done with any set of numbers.  Could someone illuminate for me how i can use non powers of 2 in a bitmask and still be able to avoid false positives?

Thank you!!

Rusty
</description>
		<content:encoded><![CDATA[<p>so i still have questions in regards to this&#8230;</p>
<p>Scenario:</p>
<p>91 | 92 = 95 (1011011 | 1011100 = 1011111)</p>
<p>Test:<br />
95 &#038; 91 = 91 CORRECT<br />
95 &#038; 92 = 92 CORRECT<br />
95 &#038; 93 = 93 ??<br />
95 &#038; 5 = 5 ??<br />
95 &#038; 6 = 4 ??</p>
<p>I recognize that powers of 2 should be used to avoid just this complication.  However I have a dev manager that is convinced that it can be done with any set of numbers.  Could someone illuminate for me how i can use non powers of 2 in a bitmask and still be able to avoid false positives?</p>
<p>Thank you!!</p>
<p>Rusty</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sqlgeek</title>
		<link>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-2412</link>
		<dc:creator>sqlgeek</dc:creator>
		<pubDate>Fri, 18 Mar 2005 02:35:08 +0000</pubDate>
		<guid>http://www.joestump.net/2004/06/a-quick-bitmask-howto-for-programmers.html#comment-2412</guid>
		<description>so i still have questions in regards to this...

Scenario:

91 &#124; 92 = 95 (1011011 &#124; 1011100 = 1011111)

Test:
95 &#038; 91 = 91 CORRECT
95 &#038; 92 = 92 CORRECT
95 &#038; 93 = 93 ??
95 &#038; 5 = 5 ??
95 &#038; 6 = 4 ??

I recognize that powers of 2 should be used to avoid just this complication.  However I have a dev manager that is convinced that it can be done with any set of numbers.  Could someone illuminate for me how i can use non powers of 2 in a bitmask and still be able to avoid false positives?

Thank you!!

Rusty
</description>
		<content:encoded><![CDATA[<p>so i still have questions in regards to this&#8230;</p>
<p>Scenario:</p>
<p>91 | 92 = 95 (1011011 | 1011100 = 1011111)</p>
<p>Test:<br />
95 &#038; 91 = 91 CORRECT<br />
95 &#038; 92 = 92 CORRECT<br />
95 &#038; 93 = 93 ??<br />
95 &#038; 5 = 5 ??<br />
95 &#038; 6 = 4 ??</p>
<p>I recognize that powers of 2 should be used to avoid just this complication.  However I have a dev manager that is convinced that it can be done with any set of numbers.  Could someone illuminate for me how i can use non powers of 2 in a bitmask and still be able to avoid false positives?</p>
<p>Thank you!!</p>
<p>Rusty</p>
]]></content:encoded>
	</item>
</channel>
</rss>
