Skip to main content
Participant
November 18, 2013
Question

Slider Decimal Place

  • November 18, 2013
  • 5 replies
  • 127197 views

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?

5 replies

rogerb34366362
Participant
October 12, 2023

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.

Inspiring
January 11, 2018

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.

yhorng
Participant
May 8, 2018

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

Inspiring
May 8, 2018

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.

Inspiring
December 23, 2017

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.

Participant
December 22, 2017

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

Community Expert
October 12, 2023

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

UQg
Legend
November 19, 2013

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.

Inspiring
October 29, 2015

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!

Mylenium
Legend
October 29, 2015

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