<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www2.sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Correction on bitmask handling</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/07/12/correction-on-bitmask-handling.aspx</link><description>In the article on handling bitmasks I posted the other day, I made a fatal error in the splitBitmask function . The function treated the low byte as the first byte, instead of the high byte. Therefore: 0x01 != 0x0001 ... and that is not good! So here's</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>Bitmask Handling, part 2: Bitmask reconstitution</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/07/12/correction-on-bitmask-handling.aspx#11440</link><pubDate>Sun, 25 Jan 2009 19:47:50 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:11440</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;Posting the first part of my series on bitmasks (yes, this is now officially a series) taught me a lot&lt;/p&gt;
</description></item><item><title>re: Correction on bitmask handling</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/07/12/correction-on-bitmask-handling.aspx#41550</link><pubDate>Sun, 05 Feb 2012 10:06:37 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:41550</guid><dc:creator>Eric</dc:creator><description>&lt;p&gt;I read your article and it really came in handy, as this is unfortunately precisely what I needed to do for a project of mine. I have two questions though. I deal with large sets of data where I have to query against, and the change from using a long and the &amp;amp; power method versus dealing with a function to determine which bit is set in the varbinary has been a big hit performance-wise. Do you have any ideas for this?&lt;/p&gt;
&lt;p&gt;Also, do you deal with C#? It appears when I would read or write the varbinary to C# it got it backwards, like your original suggestion on how to read the bits in the varbinary.&lt;/p&gt;
&lt;p&gt;Thanks for your help!&lt;/p&gt;
</description></item><item><title>re: Correction on bitmask handling</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/07/12/correction-on-bitmask-handling.aspx#41553</link><pubDate>Sun, 05 Feb 2012 17:58:37 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:41553</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;Hi Eric,&lt;/p&gt;
&lt;p&gt;Yes, this is much, much, much slower than using bigint and bitwise methods. Which makes perfect sense, since those operations can often be handled in a single processor operation, whereas with my expanded methods you'll wind up with many, many, many operations (hundreds? thousands? depends on how big your bitmask is and other issues). &lt;/p&gt;
&lt;p&gt;Making things much worse is the fact that this is all being done in SQL -- which is very slow with these kinds of things. My suggestion to you would be to utilize SQLCLR, but it sounds like you're already attempting that.&lt;/p&gt;
&lt;p&gt;I'm not sure what you mean about getting the values backward -- that's never happened to be before (I don't think). But if it's happening that way consistently, can't you simply reverse the logic?&lt;/p&gt;
&lt;p&gt;--Adam&lt;/p&gt;
</description></item></channel></rss>