[PD] Some more float weirdness/fun
Mathieu Bouchard
matju at artengine.ca
Fri Mar 9 09:08:17 CET 2012
Le 2012-03-09 à 08:32:00, Roman Haefeli a écrit :
> But 0.1 still cannot be represented exactly by float64, can it?
It can't. It also doesn't work for any other form of binary floating
point. It's just that float64 is a lot closer to exact than float32 can
be, and so on.
0.1 = 1/10 = 1/(2*5) in prime factors.
This means both 2 and 5 need to be present as prime factors in the base of
the format, to have an exact fraction for it. So, decimal floats obviously
can, and the only other bases that allow it are multiples of 10.
for 1/44100 = 1/(2*2*3*3*5*5*7*7), the smallest base to do it exactly is
2*3*5*7 = 210.
for 1/48000 = 1/(2*2*2*2*2*2*2*3*5*5*5), the smallest base to do it
exactly is 2*3*5 = 30.
I'm just saying that as examples of the principle for exact fractions ; in
practice, bases that aren't binary nor decimal are rarely ever used, and
decimal floats are almost only used as textfile versions of binary floats
(such as in the pd file format and most programming languages).
______________________________________________________________________
| Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC
More information about the Pd-list
mailing list