• Global community
• Language:
• Deutsch
• English
• EspaĆ±ol
• FranĆ§ais
• PortuguĆŖs
• ę„ę¬čŖć³ćć„ććć£
Dedicated community for Japanese speakers
• ķźµ­ ģ»¤ė®¤ėķ°
Dedicated community for Korean speakers
Exit
• 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

109.9K

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
17 Replies 17
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.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Engaged ,
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!

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
LEGEND ,
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

Report

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

Copied

Using  Quba for now.

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

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 Expert ,
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

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

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

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.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Engaged ,
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

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 ,
Sep 20, 2021 Sep 20, 2021

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

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

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 Expert ,
Oct 12, 2023 Oct 12, 2023

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().

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Engaged ,
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.

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.

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

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Engaged ,
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.

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.

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 ,
Oct 12, 2023 Oct 12, 2023

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.