Forums > MaxMSP

Doubles ….10 decimal resolution. Workaround?

September 24, 2012 | 9:20 am

I have a situation where I need to have an ==~ object track a phasor~ with up to 10 decimal places. Dissapointingly I can only analyse with a resolution of 6 decimals. Is there a way round this limitation?

PS At least ==~ it displays only 6 decimals. When I input a 10 decimal float number it seems to work, bizarre!


September 24, 2012 | 4:21 pm

from my understanding this almost sounds like a bug of the comparison object, but
maybe i am missing something.
any signal object in max 6 should normally take 64 bit signals in any inlets.

-110


September 24, 2012 | 7:38 pm

Your arguments are going to be in floating-point (32 bit), but processing is at 64-bits. What exactly are you trying to do? There may be another way of implementing this that works better.


September 24, 2012 | 10:04 pm

Peter, Roman, many thanks guys, you are right. I can see It only displays 32bit but I get a 64 bit result when I set folatnum…..phewww!


October 6, 2012 | 9:51 pm

Sorry didn’t include example. Here it is. It still doesn’t work. I am perplexed.

It seems like the maximum resolution achievable is 1/64

thanks for your help any way, P

– Pasted Max Patch, click to expand. –

October 6, 2012 | 11:33 pm

You’re up against the limits of 32 bit floating point here, I think.


October 7, 2012 | 2:58 am

the only thing you could do to give this argument to a signal object is to use 2 32 bit numbers and multiply them with each other _after converting them to signal using [sig~]

-110


October 7, 2012 | 2:15 pm

@ Chris Yes I think that is it. The 32 bit limit. I looked at Claytons Hires objects but there isn’t a 64 bit ==~

@ Roman, Ok I’ll try that.

The weird thing is that I can get a 10 decimal reading from number~ out of its float output, just that pesky ==~ is holding this up :-(

thanks so much everyone for giving me a hand with this.


October 7, 2012 | 5:57 pm

Why not just use a range? >=~ and < =~ and multiply those to together (for logical and). If this is the usage case you're looking at, it takes care of it perfectly. The neighborhood in this example could be quite wide since you're already reducing the bit depth, so it's not like you'll have a value that's really close anyways.

It’s generally recommended in the programming literature that you avoid testing floating point numbers for equality, and given that there’s mixed types involved, that seems to go double. To read more:

http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm


October 7, 2012 | 10:39 pm

Excellent info Peter, many thanks, great information about the unreliability of testing floats for equality. The result I get are explained by the linked article you include. Enormous thanks to everyone. I will test the range approach.


October 7, 2012 | 11:07 pm

However I must add that the testing equality works very accurately if kept within the 32bit limit and not if taken outside this. 64 bit resolution would no doubt solve my problem using the existing equality testing. I played with range but unfortunately it doesn’t solve my problem. A Shame as after many years of working with MSP (which I love) I have to migrate to an environment that can handle the needed precision.


October 8, 2012 | 12:49 am

Are you trying to do something other than what you posted? I don’t really see what the problem is, but maybe there’s something more?

My question when people go into extreme precision is "Do you really need that precision, or is just the way you want to be able to solve the problem?" In my personal experience, extreme precision and equality are rarely needed together (I can’t think of a particular signal-processing application where they are).

If you have gen~, you can store doubles inside codebox or expr, as they are evaluated as doubles. I prefer the range solution since it gives me further flexibility, but YMMV.



pid
October 8, 2012 | 9:00 am

^^^ what peter said.

"A Shame as after many years of working with MSP (which I love) I have to migrate to an environment that can handle the needed precision"

…and use gen~. then you don’t have to migrate.


October 8, 2012 | 9:48 am

I will start investigating Gen today.Just upgraded to 6 so its all fairly new. Thanks all!!


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