Activity › Forums › Adobe After Effects Expressions › Expressions: Leading zeros and decimal places.
-
Expressions: Leading zeros and decimal places.
Awesomefighter Toons replied 10 years, 6 months ago 8 Members · 12 Replies
-
Quba Michalski
August 23, 2015 at 11:35 pmIf you want to continue learning expressions, disregard this reply. If you, however just want to get things done, I recommend the free expression called UberNumber I created a while back.
https://qubahq.com/2014/06/ubernumber/
It does leading zeroes, decimal places, negative symbol before/after currency symbol, digit grouping and a few more things. The idea was to write a number expression to end all expressions and I think it works.
Quba Michalski
qubahq.com -
Awesomefighter Toons
October 27, 2015 at 3:05 amHi everyone! If you’ve stumbled upon this post and found the previous expressions don;t work then use this modified one. There was a slight typo in the last post which breaks the expression.
nums= PICKWHIP VALUE ;
amtOfZeroes= 10 ;
numOfDecimals= 3 ;//------------------------------------------------------------ ;
nums = nums.value.toFixed(numOfDecimals);
isNeg = false;
if (nums < 0)
{
nums = Math.abs(nums);
nums = nums.toFixed(numOfDecimals);
isNeg = true;
}
numsArray = nums.split(".");
numsFloat = numsArray[0];
while (numsFloat.length < amtOfZeroes)
{
numsFloat = "0" + numsFloat;
}
if(isNeg)
{
numsFloat = "-" + "0" + numsFloat;
}numsFloat + "." + numsArray[1]
Reply to this Discussion! Login or Sign Up