Strange floor() problem-Please Help!

Discuss problems and solutions.
Post Reply
Refrochia
Newbie
Posts: 9
Joined: 10 Jul 2013 15:36

Strange floor() problem-Please Help!

Post 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
Refrochia
Newbie
Posts: 9
Joined: 10 Jul 2013 15:36

Re: Strange floor() problem-Please Help!

Post 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!
Macciza
Regular
Posts: 1315
Joined: 07 Dec 2011 04:57
Location: Sydney, Australia.

Re: Strange floor() problem-Please Help!

Post by Macciza »

It has to do with pixel resolution and detection and stuff.. Also rounding vs flooring ....

Try using round instead of floor.....
MM
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: Strange floor() problem-Please Help!

Post 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.
Attachments
image.jpg
image.jpg (23.4 KiB) Viewed 991 times
Post Reply