<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: When a number isn&#039;t a number&#8230;</title>
	<atom:link href="http://www.scriptygoddess.com/archives/2003/05/27/when-a-number-isnt-a-number/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scriptygoddess.com/archives/2003/05/27/when-a-number-isnt-a-number/</link>
	<description></description>
	<pubDate>Wed, 08 Oct 2008 07:57:53 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
		<item>
		<title>By: kain</title>
		<link>http://www.scriptygoddess.com/archives/2003/05/27/when-a-number-isnt-a-number/#comment-9917</link>
		<dc:creator>kain</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2003/05/27/when-a-number-isnt-a-number/#comment-9917</guid>
		<description>you saved me,
&#60;a href='#' onclick=&#92;"myimage_onclick('".$fuser-&#62;getVar("rf_clienti")."');&#92;"&#62;".$fuser-&#62;getVar("rf_clienti")."&#60;/a&#62;

I added the '' to the function and now it return the correct value instead of a octal number, parseInt just stripped the zeroes,
thank tou.
</description>
		<content:encoded><![CDATA[<p>you saved me,<br />
&lt;a href=&#039;#&#039; onclick=&#92;&#034;myimage_onclick(&#039;&#034;.$fuser-&gt;getVar(&#034;rf_clienti&#034;).&#034;&#039;);&#92;&#034;&gt;&#034;.$fuser-&gt;getVar(&#034;rf_clienti&#034;).&#034;&lt;/a&gt;</p>
<p>I added the &#034; to the function and now it return the correct value instead of a octal number, parseInt just stripped the zeroes,<br />
thank tou.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://www.scriptygoddess.com/archives/2003/05/27/when-a-number-isnt-a-number/#comment-9916</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2003/05/27/when-a-number-isnt-a-number/#comment-9916</guid>
		<description>Just to round this out --

Normal, decimal (base 10) numbers work like we all learned - the rightmost digit is the ones, the next towards the left is the tens, then the hundreds, and so forth.

So, 156 is 6 ones, 5 tens, and 1 hundred.

To get to other bases, we've got to not think of that as ones, tens, and hundreds, but 10^0, 10^1, and 10^2.  (That's ten to the zeroth power, ten to the first power, ten squared, and so on.)  Ten to the zeroth is one, ten to the first is one, ten squared is ten times ten is one hundred, et cetera.

This is cool because we know the base is 10, and all the digits are 10 to a power.  And, starting from the right, the power starts at 0 and increases by one.

Now enter binary, which is base 2.  If we wanted a binary number, then instead of 10 to a power, we have 2 to a power.  That makes the rightmost digit the ones (2^0), the next digit the "twos" (2^1), the next digit the "fours" (2^2), the next digit the "eights" (2^3), and so on.

The other catch with bases is that any particular digit can't be equal to higher than the base.  So, in binary, each digit can only be a 0 or a 1.  In decimal, each digit can only be 0 through 9.  The reason is that, if I had 2 in binary, it's the same as 10 in binary.  So, the digits only go up to 1.  Decimal digits only go to 9, not ten.

So, let's take an example number in binary:
11010
This is:
No ones (2^0)
One two (2^1)
No fours (2^2)
One eight (2^3)
One sixteen (2^4)

Sixteen plus eight plus two is twenty-six, so 26 base 10 is the same as 11010 base 2.

See the pattern?

Octal is base 8.  So, we'd have ones (8^0), eights (8^1), sixty-fours (8^2), et cetera.  And, each digit goes from 0 to 7.

Example:  50 base 8 is five eights and no ones, which is forty in decimal.

What they've said about the leading zero is that the leading zero is the indication to the computer that you are giving it an octal, not decimal number.  If I just saw:
25
then I wouldn't know if it were base 8 or base 10.  By convention, that is a decimal (base 10) number, and if I fed it:
025
it knows the leading 0 says this is an octal number.

Hexadecimal works the same way, but in sixteens.  Letters are used for ten and above; hexadecimal (abbreviated hex) digits are 0,1,2,3,...,8,9,A,B,C,D,E,F.

Example:
0x1A6 is one two-hundred-fifty-six (16^2), ten sixteens (16^1), and six ones (16^0).  That makes, um, 422, I think.  (Check my math on that.)

Now you get the joke behind one of my favorite blog names, 0xDECAFBAD.  (Why couldn't *i* come up with something like that...)</description>
		<content:encoded><![CDATA[<p>Just to round this out &#8211;</p>
<p>Normal, decimal (base 10) numbers work like we all learned - the rightmost digit is the ones, the next towards the left is the tens, then the hundreds, and so forth.</p>
<p>So, 156 is 6 ones, 5 tens, and 1 hundred.</p>
<p>To get to other bases, we&#039;ve got to not think of that as ones, tens, and hundreds, but 10^0, 10^1, and 10^2.  (That&#039;s ten to the zeroth power, ten to the first power, ten squared, and so on.)  Ten to the zeroth is one, ten to the first is one, ten squared is ten times ten is one hundred, et cetera.</p>
<p>This is cool because we know the base is 10, and all the digits are 10 to a power.  And, starting from the right, the power starts at 0 and increases by one.</p>
<p>Now enter binary, which is base 2.  If we wanted a binary number, then instead of 10 to a power, we have 2 to a power.  That makes the rightmost digit the ones (2^0), the next digit the &#034;twos&#034; (2^1), the next digit the &#034;fours&#034; (2^2), the next digit the &#034;eights&#034; (2^3), and so on.</p>
<p>The other catch with bases is that any particular digit can&#039;t be equal to higher than the base.  So, in binary, each digit can only be a 0 or a 1.  In decimal, each digit can only be 0 through 9.  The reason is that, if I had 2 in binary, it&#039;s the same as 10 in binary.  So, the digits only go up to 1.  Decimal digits only go to 9, not ten.</p>
<p>So, let&#039;s take an example number in binary:<br />
11010<br />
This is:<br />
No ones (2^0)<br />
One two (2^1)<br />
No fours (2^2)<br />
One eight (2^3)<br />
One sixteen (2^4)</p>
<p>Sixteen plus eight plus two is twenty-six, so 26 base 10 is the same as 11010 base 2.</p>
<p>See the pattern?</p>
<p>Octal is base 8.  So, we&#039;d have ones (8^0), eights (8^1), sixty-fours (8^2), et cetera.  And, each digit goes from 0 to 7.</p>
<p>Example:  50 base 8 is five eights and no ones, which is forty in decimal.</p>
<p>What they&#039;ve said about the leading zero is that the leading zero is the indication to the computer that you are giving it an octal, not decimal number.  If I just saw:<br />
25<br />
then I wouldn&#039;t know if it were base 8 or base 10.  By convention, that is a decimal (base 10) number, and if I fed it:<br />
025<br />
it knows the leading 0 says this is an octal number.</p>
<p>Hexadecimal works the same way, but in sixteens.  Letters are used for ten and above; hexadecimal (abbreviated hex) digits are 0,1,2,3,&#8230;,8,9,A,B,C,D,E,F.</p>
<p>Example:<br />
0&#215;1A6 is one two-hundred-fifty-six (16^2), ten sixteens (16^1), and six ones (16^0).  That makes, um, 422, I think.  (Check my math on that.)</p>
<p>Now you get the joke behind one of my favorite blog names, 0xDECAFBAD.  (Why couldn&#039;t *i* come up with something like that&#8230;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://www.scriptygoddess.com/archives/2003/05/27/when-a-number-isnt-a-number/#comment-9915</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2003/05/27/when-a-number-isnt-a-number/#comment-9915</guid>
		<description>I ran across this same problem (I think it was asp) and discovered that when a zero was added in front of a number - say 1 - it actually promoted my int to a double. Is this an undocumented feature?</description>
		<content:encoded><![CDATA[<p>I ran across this same problem (I think it was asp) and discovered that when a zero was added in front of a number - say 1 - it actually promoted my int to a double. Is this an undocumented feature?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.328 seconds -->
