# Additions of the Number Data Type

**URL:** <https://forum.kirupa.com/t/additions-of-the-number-data-type/259130>\
**Category:** flash\
**Created:** [May 1, 2008, 11:17am UTC](https://forum.kirupa.com/t/additions-of-the-number-data-type/259130 "2008-05-01T11:17:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blue\_chi](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/blue_chi/32/62_2.png) [@blue\_chi](https://forum.kirupa.com/u/blue_chi)\
**Post date:** [May 1, 2008, 11:17am UTC](https://forum.kirupa.com/t/additions-of-the-number-data-type/259130/1 "2008-05-01T11:17:02Z")

</div>

I’m trying to get the sum of two number values in an XML file, so I’m doing this:

```php
	_root.gallery_height = myGalleryXML.firstChild.attributes.height; // '200'
	_root.spacing = myGalleryXML.firstChild.attributes.vertical_spacing; // '20'

	_root.bar_y= _root.gallery_height+_root.spacing;
	trace(_root.bar_y); //outputs 20020

```

The answer is supposed to be 220, but it comes out at as 20020 because the interpreter treats then as strings.

I can fix the problem by casting the type using the Number() method this way:

```php

	_root.gallery_height = myGalleryXML.firstChild.attributes.height; // '200'
	_root.spacing = myGalleryXML.firstChild.attributes.vertical_spacing; // '20'

	_root.bar_y= Number(_root.gallery_height)+Number(_root.spacing);
	trace(_root.bar_y); //outputs 220

```

This works fine, but is it _the right_ way of doing it? Why is Flash treating my numbers as strings?
