Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How to get decimal number to show after a basic math expression?

  • How to get decimal number to show after a basic math expression?

    Posted by Maeve Tan on February 22, 2022 at 10:01 am

    Hi all, I’m working on an AE project where there’s basic math happening, but the math answer is not exactly showing what I want.

    I have 2 var where the value will be inputted and then I have my end result var and I would want the end result to show a dot/comma and the rest after that. e.g 650.000 – 490.000 = 160.000, but at the moment it just shows 160 instead. I would like it that it show the .000 after 160.

    My expression is:

    let current = comp("xComp").layerByComment("current_value").text.sourceText.valueAtTime(0);
    let start = comp("xComp").layerByComment("start_value").text.sourceText.valueAtTime(0);
    paidOff = startValue - currentValue;

    Thanks beforehand!

    Maeve Tan replied 4 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Tomas Bumbulevičius

    February 22, 2022 at 11:22 am

    You can do it by adding toFixed(X) where X is number of decimal places.

    However, I assume you are working with thousands, and you need separator instead ofa decimal.

  • Maeve Tan

    February 22, 2022 at 1:28 pm

    Thanks for your reply! This seems to indeed work.

    If I would use a separator, how should I do this? The amounts are supposed to be the amount of money.

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