<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Huddled Masses &#187; Shift Operator</title>
	<atom:link href="http://huddledmasses.org/tag/shift-operator/feed/" rel="self" type="application/rss+xml" />
	<link>http://huddledmasses.org</link>
	<description>You can do more than breathe for free...</description>
	<lastBuildDate>Fri, 27 Apr 2012 05:42:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<cloud domain='huddledmasses.org' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>PowerShell needs Shift operators &#8230;</title>
		<link>http://huddledmasses.org/powershell-needs-shift-operators/</link>
		<comments>http://huddledmasses.org/powershell-needs-shift-operators/#comments</comments>
		<pubDate>Sun, 22 Feb 2009 22:18:01 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Add-Type]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Shift Operator]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=1094</guid>
		<description><![CDATA[So earlier today someone asked how they could tell if PowerBoots graphics would be hardware accelerated on their system &#8230; and I found the question painful to answer because the answer is that you take the high-order word of the RenderCapability.Tier property, and that indicates 0, 1, or 2 &#8230; where a higher number indicates [...]]]></description>
			<content:encoded><![CDATA[	<p>So earlier today someone asked how they could tell if <a href="http://HuddledMasses.org/PowerBoots">PowerBoots</a> graphics would be hardware accelerated on their system &#8230; and I found the question painful to answer because the answer is that you take the high-order word of the <a href="http://msdn.microsoft.com/en-us/library/system.windows.media.rendercapability.tier.aspx">RenderCapability.Tier</a> property, and that indicates 0, 1, or 2 &#8230; where a higher number indicates a higher level of hardware acceleration:</p>

	<ul>
		<li><strong>Rendering Tier 0</strong> No graphics hardware acceleration. The DirectX version level is less than version 7.0.</li>
		<li><strong>Rendering Tier 1</strong> Partial graphics hardware acceleration. The DirectX version level is greater than or equal to version 7.0, and lesser than version 9.0.</li>
	</ul>
	<ul>
		<li><strong>Rendering Tier 2</strong> Most graphics features use graphics hardware acceleration. The DirectX version level is greater than or equal to version 9.0. </li>
	</ul>

<div class="zemanta-img floatright" style="border: 2px solid rgb(51, 102, 153); margin: 2px; padding: 2px;"><div><a href="http://commons.wikipedia.org/wiki/Image:Rotate_left_logically.svg"><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Rotate_left_logically.svg/202px-Rotate_left_logically.svg.png" alt="Logical and arithmetic rotate one bit left" title="Logical and arithmetic rotate one bit left" /></a><br />
<span style="font-size: 0.9em; font-weight: bold;">Shift-Left 1, via <a href="http://commons.wikipedia.org/wiki/Image:Rotate_left_logically.svg">Wikipedia</a></span></div></div>

	<p>The problem is that in PowerShell, getting the &#8220;high-order word&#8221; of an integer is a little annoying, because the normal way to do that is to right-shift the integer to throw away the low-order word &#8230; and PowerShell is missing the shift operators. Why? I don&#8217;t know. In any case, I figured, well, I&#8217;ll just write it as a function with a call out to C# to make my life simpler.  The one catch is that the Add-Type cmdlet that lets you inject C# classes is new in PowerShell 2.0, so if you want to use this script in PowerShell 1.0 you need to get the <a href="http://poshcode.org/720">New-Type</a> function from PoshCode and replace Add-Type with New-Type in the script.</p>

<span id="more-1094"></span>

	<p>I wrote a simple little static C# class to actually do the shifting, and then a pair of functions: Shift-Left and Shift-Right which can even work in the pipeline. NOTE: it assume the values are passed in by index, so when you&#8217;re in the pipeline it should only have one parameter (<code>$x</code>) which will be the shift count, but when you&#8217;re passing both as parameters to the function, $y is the shift count.</p>

<script type="text/javascript" src="http://PoshCode.org/embed/892"></script>

<div class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/23e567b3-6ecd-4888-a386-f812a192d2e7/" title="Zemified by Zemanta"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=23e567b3-6ecd-4888-a386-f812a192d2e7" alt="Reblog this post [with Zemanta]" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/powershell-needs-shift-operators/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

