Doubles ....10 decimal resolution. Workaround?

pereshaped's icon

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!

Roman Thilenius's icon

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

Peter McCulloch's icon

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.

pereshaped's icon

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!

pereshaped's icon

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

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

thanks for your help any way, P

Chris Muir's icon

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

Roman Thilenius's icon

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

pereshaped's icon

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

Peter McCulloch's icon

Why not just use a range? >=~ and

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

pereshaped's icon

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.

pereshaped's icon

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.

Peter McCulloch's icon

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's icon

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

pereshaped's icon

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