'select' not always working, why?

bdhm's icon

hello,

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

Max Patch
Copy patch and select New From Clipboard in Max.

thanks!
bd

ComfortableInClouds's icon
Luke Hall's icon

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

lh

Zachary Seldess's icon

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

best,
Zachary

bdhm's icon

hi,

thanks to you all !

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

my conclusion: 'you don't see what you get'.

greetings,
bd

Emmanuel Jourdan's icon
Max Patch
Copy patch and select New From Clipboard in Max.

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.

AlexHarker's icon

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

Macciza's icon

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???

bdhm's icon

hello to you all,

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

floating greetings....
bd