Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Need to round to the nearest .05 decimal.

  • Need to round to the nearest .05 decimal.

    Posted by Lauren Roundy on August 15, 2024 at 11:55 pm

    Hi everyone, I feel like this should be simple, but I can’t find how to do it.

    I’ve got a text layer linked up to a slider to count numbers, as you do. But I need the number to always round to the nearest .05 decimal. In other words, it has to be either 0.00 or 0.05 or 0.10 etc… Any tips would be greatly appreciated. Thanks!

    Yoan Boisjoli
    replied 3 weeks, 2 days ago
    2 Members · 2 Replies
  • 2 Replies
  • Lauren Roundy

    August 16, 2024 at 12:02 am

    Ope, I finally found the answer. I just used this:

    <code data-highlighted="yes">(Math.round(number*20)/20).toFixed(2)
  • Yoan Boisjoli

    August 16, 2024 at 11:48 am

    Hi Lauren!

    Yeah I was about to write this expression:

    sliderValue = effect(“Slider Control”)(“Slider”);

    roundedValue = Math.round(sliderValue / 0.05) * 0.05;

    roundedValue.toFixed(2);

    Hehe hope everything worked out for you.

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