<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-2%3Arbha033%2Ftask2</id>
	<title>SE250:lab-2:rbha033/task2 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.kram.nz/index.php?action=history&amp;feed=atom&amp;title=SE250%3Alab-2%3Arbha033%2Ftask2"/>
	<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-2:rbha033/task2&amp;action=history"/>
	<updated>2026-04-24T16:43:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.kram.nz/index.php?title=SE250:lab-2:rbha033/task2&amp;diff=5063&amp;oldid=prev</id>
		<title>Mark: 5 revision(s)</title>
		<link rel="alternate" type="text/html" href="https://wiki.kram.nz/index.php?title=SE250:lab-2:rbha033/task2&amp;diff=5063&amp;oldid=prev"/>
		<updated>2008-11-03T05:19:03Z</updated>

		<summary type="html">&lt;p&gt;5 revision(s)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This was the code for Task 2:&lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 int main(){&lt;br /&gt;
     int x,y;&lt;br /&gt;
     printf(&amp;quot;&amp;amp;x=%p, &amp;amp;y=%p, diff=%ld\n&amp;quot;, &amp;amp;x, &amp;amp;y, (long)(&amp;amp;x-&amp;amp;y));&lt;br /&gt;
     printf(&amp;quot;(long)&amp;amp;x - (long)&amp;amp;y = %ld\n(long)(&amp;amp;x-&amp;amp;y) = %ld\n&amp;quot;, (long)&amp;amp;x-(long)&amp;amp;y, (long)(&amp;amp;x-&amp;amp;y));&lt;br /&gt;
     return 0;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
The Output was:&lt;br /&gt;
&lt;br /&gt;
 gcc -o task2 task2.c &amp;amp;&amp;amp; ./task2.exe&lt;br /&gt;
 &amp;amp;x=0x22ccc4, &amp;amp;y=0x22ccc0, diff=1&lt;br /&gt;
 (long)&amp;amp;x - (long)&amp;amp;y = 4&lt;br /&gt;
 (long)(&amp;amp;x-&amp;amp;y) = 1&lt;br /&gt;
 &lt;br /&gt;
 Compilation finished at Tue Mar 11 11:25:20&lt;br /&gt;
&lt;br /&gt;
Question: What&amp;#039;s the difference between &amp;#039;&amp;#039;&amp;#039;(long) &amp;amp;x - (long) &amp;amp;y&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;(long) (&amp;amp;x - &amp;amp;y)&amp;#039;&amp;#039;&amp;#039;?&lt;br /&gt;
&lt;br /&gt;
Answer: &amp;#039;&amp;#039;&amp;#039;(long)(&amp;amp;x) - (long)(&amp;amp;y)&amp;#039;&amp;#039;&amp;#039; = &amp;#039;&amp;#039;&amp;#039;4&amp;#039;&amp;#039;&amp;#039;, while &amp;#039;&amp;#039;&amp;#039;(long) (&amp;amp;x - &amp;amp;y)&amp;#039;&amp;#039;&amp;#039; = &amp;#039;&amp;#039;&amp;#039;1&amp;#039;&amp;#039;&amp;#039;. I don&amp;#039;t know why this is but I need to find out.&lt;br /&gt;
&lt;br /&gt;
After speaking to john I was told that this is because C creates an illusion of memory chunks, and the first time it&amp;#039;s showing us the actual address difference is 4 bytes, since each int type is 4 bytes long, while the second time its telling us that there&amp;#039;s a difference of 1 int type between the 2 addresses.&lt;br /&gt;
([[User:Rbha033|Rbha033]] 12:22, 11 March 2008 (NZDT))&lt;br /&gt;
&lt;br /&gt;
*[[SE250:lab-2:rbha033|Back to task 1]]&lt;br /&gt;
*[[SE250:lab-2:rbha033/task3|Onto task 3]]&lt;/div&gt;</summary>
		<author><name>Mark</name></author>
	</entry>
</feed>