<?xml version="1.0" encoding="UTF-8"?>
<!--Generated by Squarespace Site Server v5.11.81 (http://www.squarespace.com/) on Sun, 05 Feb 2012 04:50:46 GMT--><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>Rob Miles' Journal</title><link>http://www.robmiles.com/journal/</link><description>The Wonderful Life (tm) of Rob Miles</description><lastBuildDate>Thu, 02 Feb 2012 20:22:36 +0000</lastBuildDate><copyright>(c) Rob Miles 2010</copyright><language>en-GB</language><generator>Squarespace Site Server v5.11.81 (http://www.squarespace.com/)</generator><item><title>When is a number not a number?</title><category>Programming</category><category>Software</category><dc:creator>Rob</dc:creator><pubDate>Thu, 02 Feb 2012 20:22:36 +0000</pubDate><link>http://www.robmiles.com/journal/2012/2/2/when-is-a-number-not-a-number.html</link><guid isPermaLink="false">49484:424394:14843999</guid><description><![CDATA[<p><a title="IMG_5863.jpg" href="http://www.flickr.com/photos/41113520@N00/6791323255/"><img border="0" alt="IMG_5863.jpg" src="http://farm8.static.flickr.com/7170/6791323255_3318398c69.jpg" /></a></p>  <p>Pop quiz. What would the following C# code do?</p>  <pre class="csharpcode"><span class="kwrd">float</span> x = 1;
<span class="kwrd">float</span> y = 0;
<span class="kwrd">float</span> result = x / y;
Console.WriteLine(result);</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<ol>
  <li>Fail to compile.</li>

  <li>Throw an overflow exception.</li>

  <li>Print “Infinity”</li>

  <li>Cause the universe to explode.</li>
</ol>

<p>Here’s the thing, the code prints the word “Infinity”. Dividing any floating point variable by zero gives a special result which is encoded into the floating point variable range as “Infinity”. Now what about this?</p>

<pre class="csharpcode"><span class="kwrd">float</span> y = 0;
<span class="kwrd">float</span> result = y / y;
Console.WriteLine(result);</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>This time we get the message “NaN”, which means “Not a Number”. Dividing zero by zero does not give a number as a result. There just isn’t a value for this quantity. The value is not as big as as infinity or as small as zero its just, well, not a number. You get the same non-result if you divide infinity by infinity. </p>

<p>The C# runtimes are based on .NET which uses an IEEE (Institute of Electrical Electronics Engineers) standard that contains representations for negative infinity, positive infinity and “not a number”. Calculations in a C# program will produce these results when given dodgy values to work on. This is very important. You might think if you do silly things with numbers in your program you are going to get an exception thrown. Like this would.</p>

<pre class="csharpcode"><span class="kwrd">int</span> i = 1;
<span class="kwrd">int</span> j = 0;
<span class="kwrd">int</span> Result = i / j;
Console.WriteLine(Result);</pre>

<p>Run this code and it throws a “Divide by Zero” exception when it tries to, er, divide by zero. But this does not happen with floating point calculations. This is probably because the range of values for the int type does not include one to represent “infinity”. </p>

<p>The bottom line here is that if you do sums involving floating point values you can’t expect exceptions to be thrown if the calculations go wrong. The good news is that you can use methods provided by the float type to test results of calculations:<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style></p>

<pre class="csharpcode"><span class="kwrd">if</span> (<span class="kwrd">float</span>.IsNaN(fresult))
    Console.WriteLine(<span class="str">&quot;Welcome to the Twilight Zone&quot;</span>);</pre>
<style type="text/css">
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<p>This prints the enigmatic message if the value in fresult is not a number.</p>]]></description><wfw:commentRss>http://www.robmiles.com/journal/rss-comments-entry-14843999.xml</wfw:commentRss></item><item><title>XNA Ebook Deal of the Day</title><category>XNA</category><dc:creator>Rob</dc:creator><pubDate>Wed, 01 Feb 2012 20:42:34 +0000</pubDate><link>http://www.robmiles.com/journal/2012/2/1/xna-ebook-deal-of-the-day.html</link><guid isPermaLink="false">49484:424394:14829834</guid><description><![CDATA[<p><a href="http://www.robmiles.com/resource/Windows-Live-Writer-XNA-Ebook-Half-Price_1207D-?fileId=16363005" rel="lightbox"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.robmiles.com/resource/Windows-Live-Writer-XNA-Ebook-Half-Price_1207D-?fileId=16363007" width="229" height="279" /></a></p>  <p>Lovers of fine literature (and those who read my books) will be thrilled to know that my XNA 4.0 book is half price today on the O’Reilly site. This is the latest version, that also covers Windows Phone game development and features words of wisdom from “The Great Programmer”.</p>  <p>Find out more <a href="http://oreil.ly/yNeFXT">here</a>. </p>]]></description><wfw:commentRss>http://www.robmiles.com/journal/rss-comments-entry-14829834.xml</wfw:commentRss></item><item><title>Living in a Box–Oh Yes</title><category>music</category><dc:creator>Rob</dc:creator><pubDate>Tue, 31 Jan 2012 20:37:00 +0000</pubDate><link>http://www.robmiles.com/journal/2012/1/31/living-in-a-boxoh-yes.html</link><guid isPermaLink="false">49484:424394:14829820</guid><description><![CDATA[<p><a rel="lightbox" href="http://www.robmiles.com/resource/Windows-Live-Writer-Living-in-a-Box_121AF-?fileId=16362977"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://www.robmiles.com/resource/Windows-Live-Writer-Living-in-a-Box_121AF-?fileId=16362978" border="0" alt="image" width="300" height="310" /></a></p>
<p>I actually own this single on 12&rdquo; vinyl. I bet it is worth a fortune now&hellip;.</p>
<p>One of the nice things about having a Zune Pass is that I can track down old bands that I used to listen to in the old days. Like <a href="http://en.wikipedia.org/wiki/Living_In_A_Box">Living in a Box</a>. I&rsquo;m sure you&rsquo;ve heard the title track of album and band. Good stuff. The rest of the album is 80&rsquo;s synth pop, but none the worse for that.</p>]]></description><wfw:commentRss>http://www.robmiles.com/journal/rss-comments-entry-14829820.xml</wfw:commentRss></item><item><title>Rob on the Road</title><category>Conferences</category><dc:creator>Rob</dc:creator><pubDate>Tue, 31 Jan 2012 20:28:00 +0000</pubDate><link>http://www.robmiles.com/journal/2012/1/31/rob-on-the-road.html</link><guid isPermaLink="false">49484:424394:14829687</guid><description><![CDATA[<p><a href="http://www.robmiles.com/resource/Windows-Live-Writer-Rob-on-the-Road_11C68-?fileId=16362717" rel="lightbox"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.robmiles.com/resource/Windows-Live-Writer-Rob-on-the-Road_11C68-?fileId=16362718" width="278" height="136" /></a></p>  <p>I’m off on my travels again next month. I’m doing sessions about Windows Phone and Kinect at TechDays in <a href="http://www.microsoft.com/belux/techdays/2012/Home.aspx">Belgium</a> and the <a href="http://www.techdays.nl/Home.aspx?lang=en">Netherlands</a> and then hopping over to <a href="http://www.sigcse.org/sigcse2012/">SIGCSE</a> in the USA to give some sessions there too. </p>  <p>The plan is to develop and maybe even publish a complete Windows Phone application during one session and then play some rather silly games during the Kinect one. Should be fun.</p>]]></description><wfw:commentRss>http://www.robmiles.com/journal/rss-comments-entry-14829687.xml</wfw:commentRss></item><item><title>Back in Lecture Mode</title><category>Life</category><dc:creator>Rob</dc:creator><pubDate>Mon, 30 Jan 2012 20:11:00 +0000</pubDate><link>http://www.robmiles.com/journal/2012/1/30/back-in-lecture-mode.html</link><guid isPermaLink="false">49484:424394:14829495</guid><description><![CDATA[<p><a title="IMG_5876.jpg" href="http://www.flickr.com/photos/41113520@N00/6791330187/"><img border="0" alt="IMG_5876.jpg" src="http://farm8.static.flickr.com/7026/6791330187_1906392909.jpg" /></a></p>  <p>The students came back to lectures today. A chance to use all those great jokes that I’ve been practicing over the break.</p>  <p>Or something.</p>]]></description><wfw:commentRss>http://www.robmiles.com/journal/rss-comments-entry-14829495.xml</wfw:commentRss></item><item><title>Crayola ColorStudio Pen</title><category>Gadgets</category><dc:creator>Rob</dc:creator><pubDate>Sun, 29 Jan 2012 20:06:00 +0000</pubDate><link>http://www.robmiles.com/journal/2012/1/29/crayola-colorstudio-pen.html</link><guid isPermaLink="false">49484:424394:14829448</guid><description><![CDATA[<p><a href="http://www.robmiles.com/resource/Windows-Live-Writer-b49de2c4a5c7_11530-?fileId=16361698" rel="lightbox"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.robmiles.com/resource/Windows-Live-Writer-b49de2c4a5c7_11530-?fileId=16361699" width="500" height="335" /></a></p>  <p>Drawing with your fingers on an iPad is fine, but not natural. The <a href="http://www.griffintechnology.com/crayola/colorstudiohd">Crayola colouring pen</a> gives you something to hold on to as you draw, which is nice. I first thought it was just a pen that works on a touch screen, but there is more to it than that. The pen does something with the connection to the screen (I think it turns it on and off quickly) that enables the software in the iPad to detect when the pen is touching it, and ignore fingers. This means that if you accidently touch the screen with your hand while drawing the program ignores this. If you (or a very small friend) want to get to grips with colouring and free hand drawing the program is worth a look. The pen works fairly reliably, although I had to press quite hard to make it work sometimes.</p>  <p><a href="http://www.robmiles.com/resource/Windows-Live-Writer-b49de2c4a5c7_11530-?fileId=16361704" rel="lightbox"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.robmiles.com/resource/Windows-Live-Writer-b49de2c4a5c7_11530-?fileId=16361749" width="240" height="183" /></a></p>  <p>The pen comes with a colouring and drawing application with pictures you can colour in which are quite fun. It has a really nice option you can set. I’ve always wanted something that helps me stay inside the lines..</p>]]></description><wfw:commentRss>http://www.robmiles.com/journal/rss-comments-entry-14829448.xml</wfw:commentRss></item><item><title>Lego Star Wars Battle of Hoth</title><category>Gadgets</category><dc:creator>Rob</dc:creator><pubDate>Sat, 28 Jan 2012 20:36:00 +0000</pubDate><link>http://www.robmiles.com/journal/2012/1/28/lego-star-wars-battle-of-hoth.html</link><guid isPermaLink="false">49484:424394:14794874</guid><description><![CDATA[<p><a title="P1030270.jpg" href="http://www.flickr.com/photos/41113520@N00/6791332741/"><img border="0" alt="P1030270.jpg" src="http://farm8.static.flickr.com/7147/6791332741_33a0f5827b.jpg" /></a></p>  <p><a href="http://www.amazon.co.uk/LEGO-Games-Star-Wars-Battle/dp/B0072SA3Z0/ref=sr_1_24?ie=UTF8&amp;qid=132">Lego Star Wars Battle of Hoth</a> is a neat little game which they say is for up to four players but works best with just two, light against dark. You take it in turns to move and attack your little Lego snow speeders and AT-ATs in an attempt to wipe out your opponents or storm their defences. It was getting quite strategic until number one son had a run of phenomenal&#160; luck (I suspect the force) and I lost. </p>  <p>Probably not worth the asking price really unless you are a Star Wars fanatic. You could spend around the same amount of money on the <a href="http://www.amazon.co.uk/LEGO-4568231-Creationary-Games/dp/B001U3Y5XE/ref=sr_1_1?s=kids&amp;ie=UTF8&amp;qid=1327956054&amp;sr=1-1">Creationary game</a> which has a lot more to it. Having said that, if you have someone little in your family who is a Star Wars nut and you want to get them used to strategy games, perhaps on the way to <a href="http://www.amazon.co.uk/United-Labels-AG-0805343-Chess/dp/B002BIRM2S/ref=sr_1_1?s=kids&amp;ie=UTF8&amp;qid=1327956294&amp;sr=1-1">chess</a>, then it is a good starting point. And being Lego they encourage you to change the rules and board shape to make it more interesting.</p>]]></description><wfw:commentRss>http://www.robmiles.com/journal/rss-comments-entry-14794874.xml</wfw:commentRss></item><item><title>Degrees of Fun</title><category>Life</category><dc:creator>Rob</dc:creator><pubDate>Fri, 27 Jan 2012 16:47:05 +0000</pubDate><link>http://www.robmiles.com/journal/2012/1/27/degrees-of-fun.html</link><guid isPermaLink="false">49484:424394:14754620</guid><description><![CDATA[<p><a title="p1.jpg" href="http://www.flickr.com/photos/41113520@N00/6771354821/"><img border="0" alt="p1.jpg" src="http://farm8.static.flickr.com/7154/6771354821_875634f666.jpg" /></a></p>  <p>Did my Graduands Marshal thing this morning. As usual I took a picture of the audience and it mostly came out OK, sorry if you are in the blurry part of the audience… There are some more of the other ceremonies on Flickr. Click on the right to find my photostream and take a look. I should have set a faster shutter speed really. I tend to fret about noise (which you get when you make the camera more sensitive to light) whereas I should remember that you can always get rid of noise, but you can’t do anything if the picture is blurred….</p>  <p>Both ceremonies were really good ones, I hope you had a good time if you were there. For me one of the the best bits was finding the chap next to me had a Nokia Lumia 800, and was liking it.</p>]]></description><wfw:commentRss>http://www.robmiles.com/journal/rss-comments-entry-14754620.xml</wfw:commentRss></item><item><title>Read Verity Stob</title><category>Life</category><dc:creator>Rob</dc:creator><pubDate>Thu, 26 Jan 2012 16:31:00 +0000</pubDate><link>http://www.robmiles.com/journal/2012/1/26/read-verity-stob.html</link><guid isPermaLink="false">49484:424394:14754517</guid><description><![CDATA[<p><a title="P1030197.jpg" href="http://www.flickr.com/photos/41113520@N00/6744145973/"><img border="0" alt="P1030197.jpg" src="http://farm8.static.flickr.com/7168/6744145973_9e0bbac822.jpg" /></a></p>  <p>I have a few hero/heroines in my life. One of them is Verity Stob. She has been writing about computers for about as long as I’ve been playing with them. I’ve mentioned her <a href="http://www.robmiles.com/crazy-archive/2005/5/22/verity-stob-lives.html">before</a>, and now I’ve discovered to my great joy that she is still writing for The Register. Her piece on exceptions is one of the best I’ve read on the subject. If you have any interest in computers you should <a href="http://www.theregister.co.uk/odds/stob/">read her stuff</a> and treasure it.</p>]]></description><wfw:commentRss>http://www.robmiles.com/journal/rss-comments-entry-14754517.xml</wfw:commentRss></item><item><title>Hull Digital for Breakfast</title><category>Conferences</category><dc:creator>Rob</dc:creator><pubDate>Wed, 25 Jan 2012 20:57:00 +0000</pubDate><link>http://www.robmiles.com/journal/2012/1/25/hull-digital-for-breakfast.html</link><guid isPermaLink="false">49484:424394:14738955</guid><description><![CDATA[<p><a href="http://hulldigital.co.uk/"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.robmiles.com/resource/Windows-Live-Writer-Hull-Digital-for-Breakfast_7A73-?fileId=16246745" width="500" height="117" /></a></p>  <p>Had a chat with Jon Moss today. He’s one of the movers and shakers behind <a href="http://hulldigital.co.uk/">Hull Digita</a>l. I’ve been to a few of their events, which are usually (and very sensibly) held at one of my favourite eating places in Hull, <a href="http://fudgefood.com/">Fudge</a> in Princes Ave. If you want to sync up with what’s happening with developers in Hull they are a great way to do this.</p>  <p>Jon was telling me about future events, including a regular programme of <a href="http://hulldigital.co.uk/hull-digital-breakfast-meetups/">Digital Breakfast MeetUps</a>, where&#160; like minded folk get together for “the most important meal of the day” every month. The next one is on Friday this week, which is a shame for me because I’m not able to go. I’m helping out with the Graduation Ceremony on the Hull campus. However, if you want to go along and meet up with digital folk - if you see what I mean- and enjoy some fantastic food (my advice, go for the omelette) then you should pop along. </p>  <p>Jon was also telling me about <a href="http://www.tedxhull.com/Root/Home/tabid/893/language/en-US/Default.aspx">TEDx</a> at Hull, which brings together a bunch of interesting folk for a day of discussion and debate about the future of, well, everything.. </p>  <p>What with that and <a href="http://www.platformexpos.com/">Platform Expo</a> coming along it looks like it is going to be an interesting few months around here.</p>]]></description><wfw:commentRss>http://www.robmiles.com/journal/rss-comments-entry-14738955.xml</wfw:commentRss></item></channel></rss>
