<?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>Bitmask Handling, part 4: Left-shift and right-shift</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/07/12/bitmask-handling-part-4-left-shift-and-right-shift.aspx</link><description>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</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>re: Bitmask Handling, part 4: Left-shift and right-shift</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/07/12/bitmask-handling-part-4-left-shift-and-right-shift.aspx#1036</link><pubDate>Tue, 27 Mar 2007 03:47:55 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:1036</guid><dc:creator>saisub</dc:creator><description>&lt;p&gt;no info regarding signed number shift..bye&lt;/p&gt;
</description></item><item><title>re: Bitmask Handling, part 4: Left-shift and right-shift</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/07/12/bitmask-handling-part-4-left-shift-and-right-shift.aspx#1273</link><pubDate>Tue, 22 May 2007 18:05:10 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:1273</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;Sorry, I kind of dropped the ball on this over two years ago. &amp;nbsp;Some day perhaps I'll revisit it, but no promises. &amp;nbsp;I'll probably use SQLCLR if I do.&lt;/p&gt;
</description></item><item><title>re: Bitmask Handling, part 4: Left-shift and right-shift</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/07/12/bitmask-handling-part-4-left-shift-and-right-shift.aspx#6926</link><pubDate>Thu, 22 May 2008 12:58:13 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:6926</guid><dc:creator>Stephen Channell</dc:creator><description>&lt;p&gt;Have I missed something.. but bit shifting can be done with the power() function.. e.g. 100 left shift 3 and right shift 3&lt;/p&gt;
&lt;p&gt;select 100 * power(2,3), convert(int, 100 / power(2,3))&lt;/p&gt;
</description></item><item><title>re: Bitmask Handling, part 4: Left-shift and right-shift</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/07/12/bitmask-handling-part-4-left-shift-and-right-shift.aspx#27459</link><pubDate>Sun, 01 Aug 2010 02:26:54 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:27459</guid><dc:creator>Justin Dearing</dc:creator><description>&lt;p&gt;Stephen,&lt;/p&gt;
&lt;p&gt;Yes you can. and I did that to do byte shifting like so:&lt;/p&gt;
&lt;p&gt;SELECT&lt;/p&gt;
&lt;p&gt;	CAST(0xFF * POWER(CAST(256 AS BIGINT), 0) AS BINARY(12)) AS Shift0,&lt;/p&gt;
&lt;p&gt;	CAST(0xFF * POWER(CAST(256 AS BIGINT), 1) AS BINARY(12)) AS Shift1,&lt;/p&gt;
&lt;p&gt;	CAST(0xFF * POWER(CAST(256 AS BIGINT), 2) AS BINARY(12)) AS Shift2,&lt;/p&gt;
&lt;p&gt;	CAST(0xFF * POWER(CAST(256 AS BIGINT), 3) AS BINARY(12)) AS Shift3,&lt;/p&gt;
&lt;p&gt;	CAST(0xFF * POWER(CAST(256 AS BIGINT), 4) AS BINARY(12)) AS Shift4,&lt;/p&gt;
&lt;p&gt;	CAST(0xFF * POWER(CAST(256 AS BIGINT), 5) AS BINARY(12)) AS Shift5&lt;/p&gt;
</description></item><item><title>re: Bitmask Handling, part 4: Left-shift and right-shift</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2006/07/12/bitmask-handling-part-4-left-shift-and-right-shift.aspx#27483</link><pubDate>Sun, 01 Aug 2010 19:01:31 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:27483</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;Stephen and Justin:&lt;/p&gt;
&lt;p&gt;Yes, that will work, but since we lack unsigned types in T-SQL you can wind up with an overflow exception if you do it like that. Anyway, these techniques are way outdated today thanks to the inclusion of SQLCLR in SQL Server 2005/2008--I certainly don't recommend actually doing this stuff for production purposes :-)&lt;/p&gt;
</description></item></channel></rss>