Adding zero to an int variable results in weird number
<p>I'm having a problem with what should be simple additon in Javascript.</p>

<p>Take a look at this firebug output:</p>

<p><img src="http://i.imgur.com/YacT4.png" alt="Firebug output screenie"></p>

<p>What I'm making is a 2D tile map in canvas, and for objects in the map that are greater than one tile in size, they have their width and height set to negative numbers, to tell me how many tiles offset in x/y they are to get to the tile with the relevant data.</p>

<p>This works fine for all cases, except when adding zero to a number.  This results in strange numbers.</p>

<p>In the image above, there are two click events fired, each starting with "clicking on X x Y" and ending with "modified x/y into X Y".  As you can see, clicking on a tile with a -3 for the Y offset works fine, but clicking on a tile with 0 for the Y offset results in 247!???  I've been going over and over this without getting any closer to an answer.  All data seems fine, right up to the point when I try and add 0 to the variable y.  If that wasn't weird enough, adding zero to the x variable works fine!</p>

<p>Here's the snippet of code that outputs the debug messages and causes the error.  x and y are parameters to a function call, and cityMap is a global 3D array.</p>

<pre><code>if (cityMap[x][y]['typeID']&lt;0)
{
    // get deffered tile pos
    console.debug("Offset x = "+cityMap[x][y]['width']);
    console.debug("Offset y = "+cityMap[x][y]['height']);  
    x += parseInt(cityMap[x][y]['width'], 10);
    y += parseInt(cityMap[x][y]['height'], 10);
    console.debug("modified x/y into x:"+x+" y:"+y);
}
</code></pre>

<p>I'm completely lost for ideas here.  Does anyone know what else I can try to stop Javascript doing this?</p>
