ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Change Decimal Mark in Dan Ebberts's Counter Expression

FAQ   •   VIEW ALL Change Decimal Mark in Dan Ebberts's Counter Expression on Jul 26, 2016 at 4:24:28 pm

Hey folks,
I'm using Dan Ebberts's counter expression (http://www.motionscript.com/design-guide/counter.html), but I would want to change the mark in front of the decimals from "." to "," which is the german way of displaying decimal numbers.
So for example 123456,789 instead of 123456.789
AE is running in english, so probably this causes the issue. It would be great if there was a solution without changing the AE language or workaround with an extra layer for the decimals...

I'm very thankful for any ideas!
Konne

```numDecimals = 3; commas = true; dollarSign = true; beginCount = -1999; endCount = 1999; dur = 4; t = time - inPoint; s = linear (t, 0, dur, beginCount, endCount).toFixed(numDecimals); prefix = ""; if (s == "-"){ prefix = "-"; s = s.substr(1); } if(dollarSign) prefix += "\$"; if (commas){ decimals = ""; if (numDecimals > 0){ decimals = s.substr(-(numDecimals + 1)); s = s.substr(0,s.length - (numDecimals + 1)); } outStr = s.substr(-s.length, (s.length-1)%3 +1); for (i = Math.floor((s.length-1)/3); i > 0; i--){ outStr += "," + s.substr(-i*3,3); } prefix + outStr + decimals; }else{ prefix + s; }```

 Return to posts index Re: Change Decimal Mark in Dan Ebberts's Counter Expressionon Jul 26, 2016 at 6:47:54 pmLast Edited By Kalle Kannisto on Jul 26, 2016 at 6:49:20 pm

Since you don't need the dollar sign and the thousand separators, you could do this:

```numDecimals = 2; beginCount = -1999; endCount = 1999; dur = 4; t = time - inPoint; s = linear (t, 0, dur, beginCount, endCount).toFixed(numDecimals); s.replace(".",",")```

 Return to posts index Re: Change Decimal Mark in Dan Ebberts's Counter Expressionon Jul 27, 2016 at 8:39:21 am

Hey Kalle, thanks for your quick response!

your suggestions seems to do the trick, but as it turns out I need those seperators.
For example 123.456,78 instead of 123,456.78.

I tried to put "s.replace("." , ",")" in the original expression, but could't get it to work.

Buuut after doing some further online research I stumbled over this sweet piece of expression, which I find pretty versitile and fits my needs perfectly.
Credit goes to Sébastien Lavoie at http://keyframed.tv/how-to-format-a-slider-control-value-as-money-in-after-...

Thanks anyways!

```spacer = " "; decimal = "."; prefix = "\$"; suffix = "¢"; isPrefixed = (effect("Show prefix")("Checkbox") == 1 ? prefix : ""); isSuffixed = (effect("Show suffix")("Checkbox") == 1 ? suffix : ""); amount = effect("Amount")("Slider"); function convertToMoney(amount) { var _sign, _prefix, _suffix; _sign = ""; _prefix = ((isPrefixed) ? prefix : ""); _suffix = ((isSuffixed) ? suffix : ""); // Removing the negative if (amount &lt; 0) { _sign = "-"; amount = -amount; } amount = parseFloat(amount).toFixed(2); amount = amount.toString().replace(/./g, function(character, index, array) { if(character === ".") { return decimal; } else if ((array.length - index) % 3 || index === 0) { return character; } else { return spacer + character; } }); return _sign + _prefix + amount + _suffix; } convertToMoney(amount);```

 Return to posts index Re: Change Decimal Mark in Dan Ebberts's Counter Expressionon Jun 26, 2019 at 5:03:04 pm

This is kind of an old post, but I got here with the same problem. I just fixed it.

In line 26 of the expression ( the original from Dan), you have:
outStr += "," + s.substr(-i*3,3);

Just replace the "," with "." and that would do the trick.

For me, it ended like below (with no decimals, without dollar sign).
Hopefully it will help someone else!

```numDecimals = 0; commas = true; dollarSign = false; beginCount = 100000; endCount = 174000; dur = 4; t = time - inPoint; s = linear (t, 0, dur, beginCount, endCount).toFixed(numDecimals); prefix = ""; if (s == "-"){ prefix = "-"; s = s.substr(1); } if(dollarSign) prefix += "\$"; if (commas){ decimals = ""; if (numDecimals > 0){ decimals = s.substr(-(numDecimals + 1)); s = s.substr(0,s.length - (numDecimals + 1)); } outStr = s.substr(-s.length, (s.length-1)%3 +1); for (i = Math.floor((s.length-1)/3); i > 0; i--){ outStr += "." + s.substr(-i*3,3); } prefix + outStr + decimals; }else{ prefix + s; }```

-MiL-

 Return to posts index