[PD] Ideas about double precision
José de Abreu
abreubacelar at gmail.com
Thu Sep 3 03:29:42 CEST 2020
Hello list, i'm excited about some possibilities of double precision, and i
had some ideas, but instead of making an issue on github, i think that
would be interesting to put here, so maybe this would create some
discussion if these make sense before asking a feature request haha
As this is implemented now, I noticed that when you type on boxes, numbers
get truncated so you lose precision and there was a good argument on github
that is best to show 440 instead of 439.99999243521 or something like that.
But what if we could type an extra d to show to pd that we want to keep
that number in full precision?
It would be, for example [* 3.1415926535d] and voila, pd doesn't truncate
to [* 3.14159]
and this could be used in other contexts, print could receive a flag -d to
show full precision on console, so [print -d] would be the decision of the
user to not truncate numbers, and maybe number boxes could have one flag in
the properties so the user could choose if he want to see the number full
or truncated, what do you think?
But one thing that i missed that is the really the reason that i am
thinking about this, is that in data structures, the numbers are also
truncated, and i was excited to see pd double precision to be able to
record these numbers in data structures, so, what about introducing double
to force data structures to keep these as double? the struct object could
be, for example [struct foo float x float y double piJustForExample double
myAnotherNumber] and then in the file maybe this large number would be in
this other format, 3.1415926535d with d appended.
In my use case, i have an old patch that used data structures to calculate
frequencies from ratios, and this keep the ratios as a fraction, numerator
and denominator separately, so i could show the ratios and do some crazy
math with harmonics and subharmonics, and when i multiply many times these
numbers were truncated by lost in precision, so i wasn't able to multiply
and then come back as the numbers were getting large and start to give
errors (not real errors, just wrong numbers, as they were lost in the
process), i know this is confusing and over simplified, but if i could keep
these numbers with full precision i would be very happy haha
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pd-list