### Counting to 100.000.000

Posted:

**06/23/2009, 2:37 am**
by **tonyworks**

Hello everybody,

I'm working on a scientific animation and i need a number to animate from 0 to 100.000.000

pausing at several numbers like 50, 1.000, 10.000 etc...

AE number count only goes up to 30000 and i'm trying to get a dot(.) instead of a comma(,) for the numbers over 1.000...

I found this using google

http://trelhouse.com/article/41/after-e ... over-30000but it doesn't seem to work....

who knows the solution??

Thanks a lot!

T.

### Re: Counting to 100.000.000

Posted:

**06/23/2009, 2:56 am**
by **tonyworks**

almost there!

i found this and it counts up to 1.000.000 but i can't get it to count to 1.000.000.000

----

Formatting a number with commas

1. Create a comp. Name it anything you like.

2. Create a new text layer and name it "dummy" (this layer can be turned off; it feeds a number to the final text layer. I haven't found a way around this; please let me know if there's another way).

3. Add a slider to the "dummy" layer (Effects > Expression Controls > Slider Control). After Effects should automatically name the slider control "Slider"

4. Add an expression to Source Text of "dummy" (Animation > Add Expression).

5. Pickwhip the expression to the "Slider" control from step 3.

6. Create a second text layer. This will be the layer that displays the formatted number.

7. Add an expression to Source Text of the new text layer. Replace the code with the following:

var num = thisComp.layer("dummy").text.sourceText;

num = Comma(num);

[num]

function Comma(number)

{

number = '' + Math.round(number);

if (number.length > 3)

{

var mod = number.length % 3;

var output = (mod > 0 ? (number.substring(0,mod)) : '');

for (i=0 ; i < Math.floor(number.length / 3); i++)

{

if ((mod == 0) && (i == 0))

output += number.substring(mod+ 3 * i, mod + 3 * i + 3);

else

output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);

}

return (output);

}

else return number;

}

Now try changing the value of the "Slider" control. Your visible text layer should reflect that number, now formatted with commas. Two catches: it only works for integers, and the slider tops out at 1,000,000. You should be able to pickwhip to any propery that contains a number (decimals are rounded off automatically).

### Re: Counting to 100.000.000

Posted:

**06/23/2009, 5:22 am**
by **Mylenium**

### Re: Counting to 100.000.000

Posted:

**05/21/2015, 10:25 am**
by **davdalx**

tonyworks wrote:almost there!

i found this and it counts up to 1.000.000 but i can't get it to count to 1.000.000.000

----

Formatting a number with commas

1. Create a comp. Name it anything you like.

2. Create a new text layer and name it "dummy" (this layer can be turned off; it feeds a number to the final text layer. I haven't found a way around this; please let me know if there's another way).

3. Add a slider to the "dummy" layer (Effects > Expression Controls > Slider Control). After Effects should automatically name the slider control "Slider"

4. Add an expression to Source Text of "dummy" (Animation > Add Expression).

5. Pickwhip the expression to the "Slider" control from step 3.

6. Create a second text layer. This will be the layer that displays the formatted number.

7. Add an expression to Source Text of the new text layer. Replace the code with the following:

var num = thisComp.layer("dummy").text.sourceText;

num = Comma(num);

[num]

function Comma(number)

{

number = '' + Math.round(number);

if (number.length > 3)

{

var mod = number.length % 3;

var output = (mod > 0 ? (number.substring(0,mod)) : '');

for (i=0 ; i < Math.floor(number.length / 3); i++)

{

if ((mod == 0) && (i == 0))

output += number.substring(mod+ 3 * i, mod + 3 * i + 3);

else

output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);

}

return (output);

}

else return number;

}

Now try changing the value of the "Slider" control. Your visible text layer should reflect that number, now formatted with commas. Two catches: it only works for integers, and the slider tops out at 1,000,000. You should be able to pickwhip to any propery that contains a number (decimals are rounded off automatically).

Thanks A LOT! This was very helpful! I wish I could understand what was going on so I wouldn't have to come back here every time. Got lost at number.length % 3.

### Re: Counting to 100.000.000

Posted:

**06/3/2016, 3:06 am**
by **lrntbb2**

you can also use vdodna's Counter Preset, to save all the time of coding and head bashing :

http://www.vdodna.com/products/counter-preset/
### Re: Counting to 100.000.000

Posted:

**10/24/2017, 9:00 pm**
by **tyrone_perry**

Just to modify the code above to not use a dummy layer...

1. Create text layer.

2. Add a slider control

3. paste this into source text.

var num = effect("Slider Control")("Slider")*1000 // *1000 this makes the slider be able to go beyond 1,000,000, up to 1,000,000,000

num = Comma(num);

[num] // Altering this to say something like ["$"+num] or [num+"%"] to add a dollar sign or percent to the number.

function Comma(number)

{

number = '' + Math.round(number);

if (number.length > 3)

{

var mod = number.length % 3;

var output = (mod > 0 ? (number.substring(0,mod)) : '');

for (i=0 ; i < Math.floor(number.length / 3); i++)

{

if ((mod == 0) && (i == 0))

output += number.substring(mod+ 3 * i, mod + 3 * i + 3);

else

output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);

}

return (output);

}

else return number;

}

// Your welcome. ha ha @tyrone_perry

### Re: Counting to 100.000.000

Posted:

**10/11/2018, 9:20 am**
by **martycg**

this is great!

Is there a way so that the tracking distance between the numbers doesn't fluctuate?