• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Slider Decimal Place

New Here ,
Nov 17, 2013 Nov 17, 2013

Copy link to clipboard

Copied

I am using the slider tool to blur a set of numbers up from 0 to 2.9. Initially, I had the issue that the numbers entered had four decimal places  (ex. 2.1253 ) I only needed one decimal place. I found this expression to round up.

Math.round(effect("Slider Control")("Slider"))

Unfortunatey, this shows no decimal places and I need to just show one decimal place but cannot find an expression online that is word for word the expression I need.

Basically I need to go to the tenth decimal place. so from 0 to 2.9, does anyone know the exact expression for this?

TOPICS
Expressions

Views

109.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 19, 2013 Nov 19, 2013

Copy link to clipboard

Copied

If you want 1 decimal in all situations, even if the number is an integer, use effect("Slider Control")("Slider").value.toFixed(1);

Otherwise:

x = effect("Slider Control")("Slider");

Math.round(10*x)/10;

Xavier.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 29, 2015 Oct 29, 2015

Copy link to clipboard

Copied

HI

This gives me 1 decimal place which is great, was finding that hard, but not "40.0" so the "%" sign I have on the end moves around.

Maybe .valuetoFixed is deprecated in newer CC versions?

Or maybe I am just stupid!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 29, 2015 Oct 29, 2015

Copy link to clipboard

Copied

You need to append the string and possibly build it manually. Something like this perhaps:

mSlider=effect("XYZ")("Slider");

mDigits=4;

mValue=mSlider.toString();

mString=mValue.toFixed(1);

mLength=mString.length;

if (mLength < mDigits)

{oString=mString+".0"}

else

{oString=mString}

[oString]

Mylenium

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 29, 2015 Oct 29, 2015

Copy link to clipboard

Copied

Head just exploded Scanners style...

Using  Quba for now.

Quba HQ » QHQ ÜberNumber (Tutorial + Preset)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 29, 2015 Oct 29, 2015

Copy link to clipboard

Copied

Alternatively, the counter iExpressions from the Source Text Bundle also offer easy and flexible formatting of numbers:

counter_numbers_0.png

Counter Numbers Expression | mamoworld

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 04, 2016 Nov 04, 2016

Copy link to clipboard

Copied

Sorry, saw your question late.

In effect("Slider Control")("Slider").value.toFixed(1); there is a dot (.) between "value" and "toFixed",

ie it's not valuetoFixed(1) but .value.toFixed(1).

Xavier

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 25, 2016 Nov 25, 2016

Copy link to clipboard

Copied

Align your text box right - then the % will stay in the same place. The numbers to the left will continue to move though.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 25, 2016 Nov 25, 2016

Copy link to clipboard

Copied

Er, exactly. Obviously i thought of that. Uber number is the best way, once you have added sliders to it and saved a preset.

Ultimately i guess the best thing is to use a separate text layer for each integer, scripted to show either tens, hundredths etc. That could be centrally aligned so not move. Might try on Monday just for kicks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 20, 2021 Sep 20, 2021

Copy link to clipboard

Copied

I found an easy way to set this up.  

In addition to the data sliders,  I created a slider called "precision", which will have values like 1,2,3,...

This allows you to control the precision of data from mulitple sliders with top-level control


I use the pow() function to convert to powers of 10

precision= 1 rounds to 1 decimal place,  precision= 2 rounds to 2 decimal places, etc

full expression:

x=Math.round(thisComp.layer("CONTROL_LAYER").effect("precision")("Slider"))
x=Math.pow(10,x)
Math.round(thisComp.layer("DATA_LAYER").effect("slider_name")("Slider")*x)/x

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 22, 2017 Dec 22, 2017

Copy link to clipboard

Copied

there is much easy way to do this: Math.round(effect("Slider Control")("Slider"))/10

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 12, 2023 Oct 12, 2023

Copy link to clipboard

Copied

LATEST

If you use toFixed(2), you will always get 2 decimal places. toFixed(1) gives you one decimal place. That is an easier workflow than fiddling with Math.round().

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 23, 2017 Dec 23, 2017

Copy link to clipboard

Copied

Hi

Er n no kornbif, that is just a tiny part of this, already discussed.

So i finally did this the other day.

It is funny how nobody else either understood there was a problem, or offered the solution.

Now i can build counters with any font.

You need a seperate layer for each integer.

You need to pick which number in sequence it is, missing out decimal points.

It is the only way to keep the number still.

I'll see if i can share it when i go back to work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 10, 2018 Jan 10, 2018

Copy link to clipboard

Copied

the easiest expression I've found to do this is this:

effect("Slider Control")("Slider").value.toFixed(1)

the number at the end of the expression defines the number of decimal places.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 08, 2018 May 08, 2018

Copy link to clipboard

Copied

Its great. Now the number will goes like this 7.8, 7.9, and 8.
How to make it to 8.0. Which iI need the "0".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 08, 2018 May 08, 2018

Copy link to clipboard

Copied

USE uberNUmber!

really

it has all the options you would need.

(apart from keeping any font centred, see above!)

let's you set decimal place and leading zeros.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 08, 2018 May 08, 2018

Copy link to clipboard

Copied

effect("Slider Control")("Slider").value.toFixed(1)

the number at the end of the expression defines the number of decimal places.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 12, 2023 Oct 12, 2023

Copy link to clipboard

Copied

I know its an old thread but this worked for me, from a video by Nick Khoo: https://youtu.be/j3HftxMxbfs?si=kTD7r0rpxqxWBs7w

s = "" + (effect(1)(1)[0]).toFixed(1); s.replace(/\B(?=(\d{3})+(?!\d))/g, ",");

- This will only work if the point controller (or your language equivalent) is the first effect in the effects stack.

A comprehensive look at how to create numbers counting up in After Effects and create a preset for it so you never have to make it again. In this lesson we also animate it with commas, decimal points and percentages as well as any other prefix you want to add. For numbers with commas s = "" + ...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines