On Wed, 6 Jul 2011, Martin Peach wrote:
(Also, someone could make this "an XXX bits float can store a YYY bits integer" a bit more clear as I personally still don't really understand it.
Numbers in pd's binary float format are made of three parts :
an int between 8388608 and 16777215 ;
a scale factor that is a power of two, such as 16, 8, 4, 2, 1, ½, ¼, ⅛, 1/16, etc ;
a sign which is either -1 or +1.
They all get multiplied together.
Thus if you have a number that is at least 1 but less than 2, it has to have a scale factor of 1/8388608 (that is, downscaling by 23 levels). Thus there are 8388608 float fractions from 1 to 2 (again not including 2).
A number from 8388608 to 16777215 has a scale factor of 1, thus there are no fractions in that range. From 16777216 to 33554430 there are no odd numbers anymore, and in the next range, there are only multiples of 4, etc.
It's worse than that though. Pd uses the %g format specifier when it writes out the pd patch (e.g. printf("%g", number)), so floats get simplified.
Numbers in pd's decimal float format are made of three parts :
an int between 100000 and 999999 ;
a scale factor that is a power of ten, such as 1000, 100, 10, 1, 1/10, 1/100, 1/1000, etc ;
a sign that is either -1 or +1.
Thus for floats between 100000 and 999999 there are only integers, and beyond that, you have only multiples of ten. Between 1 and 10, there are 900000 numbers (not including 10 itself).
Other binary and decimal float formats mostly only differ by number of digits in the «first» part of the number. So-called «double» floats use ints between 4503599627370496 and 9007199254740991, but this amount of precision is not available as part of pd messages.
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC