Page 1 of 1

Strange floor() problem-Please Help!

Posted: 12 Feb 2015 14:01
by Refrochia
Hi There!

Hoping someone can help with a strange problem I'm seeing. Hopefully something simple!

I'm using the floor function to thin a multislider value. It can be reproduced easily -

If I have a multislider that I would like to output values between 0-100 I use the following line in a script that is triggered by a change to the slider value (x):

test=floor(x*100);

Setting up 2 monitors - 1 for the slider value multiplied by 100 and another to monitor the test variable. The slider value will get to 100 but the test variable will never go higher than 99

Does anybody know why this is? It seems to be rounding 100.000 down to 99 which does doesnt make sense or am I missing something?

Thanks
R

Re: Strange floor() problem-Please Help!

Posted: 12 Feb 2015 15:12
by Refrochia
OK this is strange!!
I increased the precision of the multislider monitor from 3 to 9 and realised the issue is that the slider was not getting all the way to value 1

I then messed around with the sizing of the slider and now its working? Gets to value 1 and the floor function is returning the correct value.

The wierd thing is, I had the problem in the project I'm working on so I loaded a blank project and reproduced the error at which point I created this topic.

I've now just gone back to my project and confirmed that the slider is not reaching 1. I messed around with the size and hey presto - its working as it should now!

Re: Strange floor() problem-Please Help!

Posted: 13 Feb 2015 21:31
by Macciza
It has to do with pixel resolution and detection and stuff.. Also rounding vs flooring ....

Try using round instead of floor.....
MM

Re: Strange floor() problem-Please Help!

Posted: 16 Feb 2015 21:54
by Softcore
Round should work, but the truth is, a Multislider also should be able to reach x = 1. Which it doesnt on an iPad 2 here.