# Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions whole number slider

• # whole number slider

Posted by on November 1, 2012 at 6:58 am

I am new to expressions and sliders – is it possible to create a slider that only works with whole numbers, no decimals?

replied 3 weeks ago 6 Members · 19 Replies
• 19 Replies

November 1, 2012 at 1:32 pm

copy the following expression into your Slider:

Math.floor(value);

Math.floor rounds down whatever number is inside the bracket.

I hope this helps.

JimJam•Graphics
https://www.jimjamgraphics.com/

• ### Darby Edelen

November 1, 2012 at 3:14 pm

Math.floor rounds down whatever number is inside the bracket.”

There’s also:

`Math.round()`

Rounds to the nearest number, Math.round(0.5) returns 1, Math.round(0.4) returns 0 for example

`Math.ceil()`

Returns next highest whole number, Math.ceil(0.0001) returns 1 for example

And to complete the picture:

`Math.floor()`

Returns next lowest whole number, Math.floor(1.9) returns 1 for example

Darby Edelen

• ### Ben Wolfinsohn

November 1, 2012 at 4:29 pm

sorry, this is the first slider and expression i’ve ever made, where do i paste that exactly?
thanks!

• ### Darby Edelen

November 1, 2012 at 5:36 pm

[ben wolfinsohn] “sorry, this is the first slider and expression i’ve ever made, where do i paste that exactly?
thanks!”

That depends. If you just want to take the slider value and round it then your entire expression (applied to the slider property) might look like this:

`Math.round(value);`

You could use floor() or ceil() alternatively.

Darby Edelen

• ### Ben Wolfinsohn

November 12, 2012 at 11:02 pm

I’m still seeing the decimal point in the slider bar. is there no way to remove that then?

• ### Dan Ebberts

November 13, 2012 at 12:32 am

If you’re using a text layer, you could use a source text expression like this:

s = effect(“Slider Control”)(“Slider”).value;
s.toFixed(0)

Dan

• ### Ben Wolfinsohn

November 13, 2012 at 1:04 am

sorry, i’m a bit confused. let me try to explain.

I have 3 comps, each comp is time remaped, each remap has an expression like this –

and all 3 of the comps are pointing to the same slider.

so where would i put the code you’re talking about? and would I put it in all 3 comps?

• ### Dan Ebberts

November 13, 2012 at 1:58 am

Now I’m confused. If you’re not displaying the value, why do you care about the decimal point?

Is it that you have the rounding expression applied to the slider, but when you divide that value by 23.976 you don’t get a whole number? How about something like this instead:

Dan

• ### Ben Wolfinsohn

November 13, 2012 at 2:44 am

that didn’t seem to do it.

basically i have a comp with 18 frames, each frame has a drawing of a different perspective of a head. with the slider i can easily scroll through the different faces when i use it with timeremaping. the slider goes from 0-17. BUT, I don’t need the slider to display 1.3 for an example, cuz i don’t have .3 of a frame. i only need it to show numbers 0-17 in the slider bar.

does that make sense? is it possible?

• ### Dan Ebberts

November 13, 2012 at 3:22 am

If you put the Math.floor(value) expression on the slider, you’ll get 0.00, 1.00, etc., but I don’t think there’s any way to get rid of the “.00” part, if that’s what you’re asking.

Dan

Page 1 of 2

We use anonymous cookies to give you the best experience we can.