On Sun, Apr 8, 2012 at 1:33 PM, Matteo Sisti Sette matteosistisette@gmail.com wrote:
On 04/08/2012 04:58 AM, Martin Peach wrote:
It's because Pd saves the value by printing it as text into the patch file using a reduced precision format specifier (%g instead of %f, or %0.6f) so that the numbers look good on screen, with no extra zeros for example. I don't like it either.
I wonder how can anyone possibly like that
I've once compiled (vanilla) Pd with the format specifiers changed to print up to 8 significant digits, and soon found why it is normally done with 6 digits max. You get things like this:
33 * 0.3 = 9.900001
That is because binary numbers round differently than decimal numbers. The default format with maximum 6 significant digits avoids some of the confusion, but some (rare) inconsistencies still happen with 6 significant digits, like this one:
7.1 - 7 = 0.0999999
In MaxMsp this is handled like so: if the numbox is too small to show the 0.0999999, it shows 0.1 followed by however many trailing zero's fit in the numbox. Pd instead, shows 0.09 if the numbox width is 4. Also in MaxMsp you can create for example [* 1073741824.] (2^30, a number which can be expressed with exactness in single precision float format). If you try to create [* 1073741825.], it automatically creates [* 1073741824.], because 1073741825. can't be expressed in single precision.
Would be super to have such careful handling and storage of floats in Pd. MaxMsp demonstrates that it is somehow possible.
Katja