## Doubles ….10 decimal resolution. Workaround?

Sep 24, 2012 at 9:20am

# Doubles ….10 decimal resolution. Workaround?

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!

#64474
Sep 24, 2012 at 4:21pm

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

#232587
Sep 24, 2012 at 7:38pm

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.

#232588
Sep 24, 2012 at 10:04pm

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!

#232589
Oct 6, 2012 at 9:51pm

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. –
#232590
Oct 6, 2012 at 11:33pm

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

#232591
Oct 7, 2012 at 2:58am

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

#232592
Oct 7, 2012 at 2:15pm

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

#232593
Oct 7, 2012 at 5:57pm

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

#232594
Oct 7, 2012 at 10:39pm

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.

#232595
Oct 7, 2012 at 11:07pm

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.

#232596
Oct 8, 2012 at 12:49am

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.

#232597
Oct 8, 2012 at 9:00am

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

#232598
Oct 8, 2012 at 9:48am

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

#232599

You must be logged in to reply to this topic.