<?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>CuriousFind &#187; ActionScript 3</title>
	<atom:link href="http://www.curiousfind.com/blog/category/as3/feed" rel="self" type="application/rss+xml" />
	<link>http://www.curiousfind.com/blog</link>
	<description>Web development by Jamie McDaniel</description>
	<lastBuildDate>Tue, 13 Dec 2011 05:20:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>AS3 and Big Numbers</title>
		<link>http://www.curiousfind.com/blog/183</link>
		<comments>http://www.curiousfind.com/blog/183#comments</comments>
		<pubDate>Wed, 27 Jan 2010 16:08:53 +0000</pubDate>
		<dc:creator>Jamie McDaniel</dc:creator>
				<category><![CDATA[ActionScript 3]]></category>

		<guid isPermaLink="false">http://www.curiousfind.com/blog/?p=183</guid>
		<description><![CDATA[I ran into a problem when transferring large numbers between the client and server. They would send me a number and when I sent it back to them it would be different. Turns out ActionScript 3 has problems with big numbers. Here is a quick example. The expected output would be 129090238754375001. var string:String = [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into a problem when transferring large numbers between the client and server.  They would send me a number and when I sent it back to them it would be different.  Turns out ActionScript 3 has problems with big numbers. Here is a quick example. The expected output would be 129090238754375001.</p>
<div class="actionscript geshi no actionscript" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">var</span> <span class="kw3">string</span>:<span class="kw3">String</span> = <span class="st0">&quot;129090238754375000&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">var</span> <span class="kw3">number</span>:<span class="kw3">Number</span> = <span class="kw3">Number</span><span class="br0">&#40;</span><span class="kw3">string</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">var</span> nextNumber = <span class="kw3">number</span> + <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">trace</span><span class="br0">&#40;</span>nextNumber<span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>Here are the variables after execution.  Notice that both number and nextNumber are 129090238754375008.</p>
<p><img src="http://www.curiousfind.com/blog/wp-content/uploads/FlashScreenSnapz002.jpg" alt="Screenshot showing variables at breakpoint" title="FlashScreenSnapz002" width="415" height="456" class="alignnone size-full wp-image-184" /></p>
<p>And the output window:</p>
<p><img src="http://www.curiousfind.com/blog/wp-content/uploads/FlashScreenSnapz003.jpg" alt="Output window showing 129090238754375000" title="FlashScreenSnapz003" width="459" height="82" class="alignnone size-full wp-image-185" /></p>
<p>So <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/int.html">int</a> has a range of -2,147,483,648 to 2,147,483,647 and <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/uint.html">uint</a> has a range of 0 to 4,294,967,295.  While <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Number.html">Number</a> can represent integers outside the range of int and uint, it has precision limitations.</p>
<p>The solution in our case was that, since we were not doing any math and just using it as an identifier, we changed the server code to use a string instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.curiousfind.com/blog/183/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

