# FL MX - Formatting numbers to comma separate 1000's

**URL:** <https://forum.kirupa.com/t/fl-mx-formatting-numbers-to-comma-separate-1000s/12238>\
**Category:** flash\
**Created:** [January 28, 2003, 7:56pm UTC](https://forum.kirupa.com/t/fl-mx-formatting-numbers-to-comma-separate-1000s/12238 "2003-01-28T19:56:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnLawton](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/johnlawton/32/42_2.png) [@JohnLawton](https://forum.kirupa.com/u/JohnLawton)\
**Post date:** [January 28, 2003, 7:56pm UTC](https://forum.kirupa.com/t/fl-mx-formatting-numbers-to-comma-separate-1000s/12238/1 "2003-01-28T19:56:07Z")

</div>

Hi

I have a bunch of text fields that display numbers such as 2745345

What i want is a neat bit of code that quickly and simply converts this to 2,745,345

This makes the numbers more easy to read and interpret.

Has anyone got a neat way of doing this?

Any help most gratefuly received

Cheers

John 🙂

:sigh:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 28, 2003, 8:06pm UTC](https://forum.kirupa.com/t/fl-mx-formatting-numbers-to-comma-separate-1000s/12238/2 "2003-01-28T20:06:54Z")

</div>

[http://proto.layer51.com/d.aspx?f=164#c545](http://proto.layer51.com/d.aspx?f=164#c545)

this is fun too 😉  
[http://proto.layer51.com/d.aspx?f=622](http://proto.layer51.com/d.aspx?f=622)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 28, 2003, 11:58pm UTC](https://forum.kirupa.com/t/fl-mx-formatting-numbers-to-comma-separate-1000s/12238/3 "2003-01-28T23:58:05Z")

</div>

luv those string manipulations…

```auto

Number.prototype.addCommas = function(n){
	n = this.toString();
	var l = n.length;
	var a = [];
	while((l-=3)>0){
		a.unshift(n.substr(l,3));
	}
	a.unshift(n.substr(0,3+l));
	return a.join(",");
}

n = 427453458492;
trace(n.addCommas());
// traces 427,453,458,492 (as a string)

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [January 29, 2003, 9:41am UTC](https://forum.kirupa.com/t/fl-mx-formatting-numbers-to-comma-separate-1000s/12238/4 "2003-01-29T09:41:39Z")

</div>

Marvellous - all examples led me to a solution - thanks one and all

John :beam:
