Browse by Tags
» bitmasks (RSS)
Sorry, but there are no more tags available to filter with.
Quick installment this time. Left-shift and right-shift operators.
Left-shift and right-shift are integral to binary mathematical
operations as they have two important qualities: Left-shifting a
bitmask once multiplies by two. Right-shifting once divides by two. For
0011 (base 2) = 1 + 2 = 33 << 1 = 0110 (base 2) = 4 ...
It's been longer than I hoped since my last installment on bitmask / big number handling.
Life caught up with me and I've had many thankless tasks to catch up
on. But that's over now and I'm back to the general slacking that
typifies my days, so welcome to Part 3, handling logical operators.
I'll be discussing four operators in this post. AND, ...
Posting the first part
of my series on bitmasks (yes, this is now officially a series) taught
me a lot about my readers: You don't care about handling bitmasks in
the database. And I respect you for that! I'm overjoyed, as a matter of
fact! That article has received the least hits of anything I've posted
in this blog to date. So good for you ...
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 a corrected version that fixes the problem:
CREATE FUNCTION ...
Continuing in my series of things you should probably not do in SQL Server but sometimes have to, I'm going to do a few posts on dealing with very large bitmasks.
Let me first state my utter hatered of bitmasks in databases. I think
they're annoying, make the system difficult to understand, and whether
or not they violate the First Normal ...