<?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>Computer Science &#8211; Xojo Programming Blog</title>
	<atom:link href="https://blog.xojo.com/tag/computer-science/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.xojo.com</link>
	<description>Blog about the Xojo programming language and IDE</description>
	<lastBuildDate>Tue, 02 Mar 2021 17:52:13 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Binary Magic with Signed Integers</title>
		<link>https://blog.xojo.com/2019/02/27/binary-magic-with-signed-integers/</link>
		
		<dc:creator><![CDATA[Norman Palardy]]></dc:creator>
		<pubDate>Wed, 27 Feb 2019 10:00:22 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Binary]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=5436</guid>

					<description><![CDATA[In binary the high bit (the one immediately following the &#038;b in Xojo code) is the "sign bit". When it's set to 1, the value is interpreted as "negative" and when it's set to 0, the value is "positive". Meaning that bit is not used as part of the "number" itself.]]></description>
										<content:encoded><![CDATA[<p>In binary the high bit (the one immediately following the &amp;b in Xojo code) is the &#8220;sign bit&#8221;. When it&#8217;s set to 1, the value is interpreted as &#8220;negative&#8221; and when it&#8217;s set to 0, the value is &#8220;positive&#8221;. Meaning that bit is <em>not</em> used as part of the &#8220;number&#8221; itself.</p>
<p><span id="more-5436"></span></p>
<p>So if we start counting up values are written as:</p>
<pre>1 =&gt; &amp;b00000001
2 =&gt; &amp;b00000010
3 =&gt; &amp;b00000011</pre>
<p>and so on until we get to:</p>
<pre>127 =&gt; &amp;b01111111</pre>
<p>Now, what&#8217;s the &#8220;next number&#8221;? That would be:</p>
<pre>&amp;b10000000</pre>
<p>which this code:</p>
<pre>Dim i As Int8 = &amp;b10000000</pre>
<p>tells you is -128.</p>
<p>What does -128 look like in something like an Int16?</p>
<pre>Dim i8 As Int8 = &amp;b10000000
Dim i16 As Int16 = i8

System.DebugLog(Bin(i8)) // &lt;&lt;&lt; shows 10000000
System.DebugLog(Bin(i16)) // &lt;&lt;&lt; shows 1111111110000000</pre>
<p>Why is the int16 have all those 1&#8217;s at the beginning? It&#8217;s because if you assign:</p>
<pre>Dim i16 As Int16 = &amp;b1000000000000000</pre>
<p>you&#8217;ll find that this is -32768 or the smallest value an Int16 can hold. When you assign a little value like -128 the &#8220;lowest&#8221; 8-bit can be copied from the int8 form and the upper 8 bits have to be copies of the &#8220;sign bit&#8221; &#8211; that first one after the &#8220;&amp;b&#8221;.</p>
<p>This is called <a href="https://en.wikipedia.org/wiki/Sign_extension">sign extension</a> and is required when you move a smaller type into a larger one &#8212; like moving an Int8 into an Int16 or an Int8 into an Int32.</p>
<p>Failing to do this for <em>signed</em> values (i.e. if the code did something like &#8220;fill the upper part with 0s&#8221;):</p>
<pre>Dim i8 As Int8 = &amp;b10000000
System.DebugLog(Bin(i8))

Dim i16 As Int16 = &amp;b0000000010000000
System.DebugLog(Bin(i16))</pre>
<p>would have the Int8 value saying it held -128 and the Int16 saying it held 128 (<em>note the sign change!</em>) and this would totally wreck trying to do any math.</p>
<p>Remember this is all necessary in order to manage the sign of an integer. It is not necessary with unsigned types such as UInt8, UInt16, etc.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Asteroid Run: Xojo&#8217;s Hour of Code 2017</title>
		<link>https://blog.xojo.com/2017/12/05/hour-of-code-2017/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Tue, 05 Dec 2017 18:42:22 +0000</pubDate>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Hour of Code]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3586</guid>

					<description><![CDATA[It's Computer Science Education Week, which also means it's time for Code.org's Hour of Code. I've put together a short 5-part series of videos (less than 25 minutes total) to show how to make a simple game in Xojo called Asteroid Run. It's super fun so give it a shot!]]></description>
										<content:encoded><![CDATA[<p>It&#8217;s Computer Science Education Week, which also means it&#8217;s time for <a href="https://code.org">Code.org&#8217;s Hour of Code</a>.</p>
<p>To share Xojo with Hour of Code, I&#8217;ve put together a short 5-part series of videos (less than 25 minutes total) to show how to make a simple game called Asteroid Run.</p>
<p><span id="more-3586"></span></p>
<p>In Asteroid Run a spaceship flies through space shooting an ever-increasing number of asteroids that are coming at you.</p>
<p><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-3593" src="https://blog.xojo.com/wp-content/uploads/2017/12/AsteroidRun.gif" alt="" width="600" height="572" /></p>
<p>To get started, <a href="http://www.xojo.com/download">download Xojo &#8211; it&#8217;s free!</a></p>
<h2>Asteroid Run Part 1: Initial Setup</h2>
<p>In part 1 you will do initial setup and add a scrolling background starfield.</p>
<p><a href="http://files.xojo.com/HourOfCode/AsteroidRun-Part1.zip">Download project</a></p>
<p><iframe title="Asteroid Run Part 1: Initial Setup" width="500" height="281" src="https://www.youtube.com/embed/avwgV1RpIP8?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
<h2>Asteroid Run Part 2: Add Spaceship</h2>
<p>In part 2, you will add the spaceship and allow it to move with the mouse.</p>
<p><a href="http://files.xojo.com/HourOfCode/AsteroidRun-Part2.zip">Download project</a></p>
<p><iframe title="Asteroid Run Part 2: Add Spaceship" width="500" height="281" src="https://www.youtube.com/embed/kpEgJ4o7_30?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
<h2>Asteroid Run Part 3: Add Missiles</h2>
<p>In part 3, you will add the missiles that are fired from the spaceship when you click the mouse.</p>
<p><a href="http://files.xojo.com/HourOfCode/AsteroidRun-Part3.zip">Download project</a></p>
<p><iframe loading="lazy" title="Asteroid Run Part 3: Add Missiles" width="500" height="281" src="https://www.youtube.com/embed/_1Dz200fYmU?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
<h2>Asteroid Run Part 4: Add Asteroids</h2>
<p>In part 4, you will add the asteroids and make the game end when an asteroid hits the spaceship.</p>
<p><a href="http://files.xojo.com/HourOfCode/AsteroidRun-Part4.zip">Download project</a></p>
<p><iframe loading="lazy" title="Asteroid Run Part 4: Adding Asteroids" width="500" height="281" src="https://www.youtube.com/embed/IgimObt1sxo?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
<h2>Asteroid Run Part 5: Finish the Game</h2>
<p>In part 5, you will finish the game by making the ship&#8217;s missiles destroys the asteroids for points.</p>
<p><a href="http://files.xojo.com/HourOfCode/AsteroidRun-Final.zip">Download finished project</a></p>
<p><iframe loading="lazy" title="Asteroid Run Part 5: Finish the Game" width="500" height="281" src="https://www.youtube.com/embed/pZuUn7QRa44?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
