Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expressions: Leading zeros and decimal places.

  • Quba Michalski

    August 23, 2015 at 11:35 pm

    If 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 am

    Hi 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]

Page 2 of 2

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy