## Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.

• Slider Decimal Place

# Slider Decimal Place

New Here ,
Nov 17, 2013 Nov 17, 2013

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

78.6K

Likes

Report

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

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.

Likes

Report

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

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!

Likes

Report

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

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

Likes

Report

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

Copied

Using  Quba for now.

Quba HQ Ā» QHQ ĆberNumber (Tutorial + Preset)

Likes

Report

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

Copied

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

Counter Numbers Expression | mamoworld

Likes

Report

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

Copied

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

Likes

Report

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

Copied

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

Likes

Report

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

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

Likes

Report

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

Copied

LATEST

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

Likes

Report

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

Copied

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

Likes

Report

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

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.

Likes

Report

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

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.

Likes

Report

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

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".

Likes

Report

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

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.

Likes

Report

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

Copied

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

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

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources
Troubleshooting FAQs
After Effects Community Recap
Getting started with After Effects