Expression counter with commas and two decimal points
Hello all,
I'm trying to get an expression counter with commas and two decimal points. I have the comma taken care of, but I can't seem to get the two decimal points to work.
Here's my current expression. As you'll see, nothing in there about decimal points. Nothing I've tried has worked for me. Thoughts?
var num = effect("Slider Control")("Slider")
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;
}
