Forums > MaxMSP

'select' not always working, why?

Oct 17 2010 | 1:45 pm


can someone explain me, why in my example [select] is not working ?
I guess [expr] is sending some ‘set’ message.
is it ?


-- Pasted Max Patch, click to expand. --

Oct 17 2010 | 2:14 pm


Oct 17 2010 | 3:48 pm

It looks like a rounding thing. Try multiplying by 10 then converting from float to [int] and [sel 9], which should do it.


Oct 17 2010 | 5:14 pm

Just pass it through a [sprintf %.1f]. Not sure why this is necessary though. Also, you might want to use [round 0.1] instead of the rounding abstraction you have (although they do behave a bit differently – with [round 0.1], 0.15 will become 0.2 – the abstraction returns 0.1 which makes it more like a floor and/or truncation function).


Oct 17 2010 | 5:37 pm


thanks to you all !

[sprintf %.1f] is doing the job.

my conclusion: ‘you don’t see what you get’.


Oct 17 2010 | 9:08 pm

It’s just the way floating points values are represented. Not everyone of them exists (just google IEEE754 for more details). It’s usually a good idea away from quality comparisons with floating numbers.

-- Pasted Max Patch, click to expand. --

Oct 17 2010 | 9:08 pm

You might want to look into floating point precision to see why this doesn’t work. This comes up quite a lot on the forum.

For a start 0.1 cannot be represented exactly in binary floating point (and neither can 0.9). If you require an exact precision to x decimal places, then the floating point format is probably not the best way to go. Some kind of fixed point format representation might be better, where most probably you end up with all integer values (as luke suggests above).

Oct 18 2010 | 7:10 am

OOps thought I posted last night
Wondering why there isn’t second inlet in "select" with one arg of ‘0.9’ . . .
It seems to not like floats???

Oct 18 2010 | 8:57 am

hello to you all,

very interesting field this IEEE754.
it is kind of new for me.

floating greetings….

Viewing 9 posts - 1 through 9 (of 9 total)

Forums > MaxMSP