math error?

Apr 15, 2013 at 2:43pm

math error?

Hi,

I’m getting an odd error, and I wonder if someone can tell me why.

When I use expr, the result of 1200.0/log(2.0) is 1731.234009

but when I do the same calculation in python or in C, the result of 1200.0/log(2.0) is 1731.234049

I know the error is small, but why is it occurring?

Max code (6.1.1) is pasted below.

Arun Chandra

– Pasted Max Patch, click to expand. –
#67722
Apr 15, 2013 at 3:20pm

This is almost certainly^W^W the result of one calculating with 32-bit floating point and the others using 64-bit.

#243582
Apr 15, 2013 at 8:18pm

expr is using lumber() internally.

#243583
Apr 16, 2013 at 9:06am

On second thought, I expect expr() is also using 64-bit floats internally. However, data passed through patch cords is truncated to 32-bits.

It may be that Max 6.1 in 64-bit mode will pass floats through patch cords with 64-bit precision. I haven’t yet worked enough with 64-bit mode to know for sure (getting there). You didn’t state whether you are using 6.1 in 32-bit or 64-bit mode.

In case you haven’t seen any of the many, many posts on this subject, 32-bit floating point is only accurate to about 6 significant decimal places. So everything after 1731.23 is just noise.

#243584
Apr 16, 2013 at 8:54pm

dito. the truncation alone makes that difference already.

#243585

You must be logged in to reply to this topic.