[PD] problem with correct numbers in pd double precision

Lucas Cordiviola lucarda27 at hotmail.com
Sun Sep 20 12:40:51 CEST 2020


Interesting I got into troubles storing big numbers into a [text] using 
the -k flag but this can be solved using [list fromsymbol] / [list 
tosymbol].

See attached patch (needs Pd-double).


--

Mensaje telepatico asistido por maquinas.

On 9/19/2020 3:38 PM, hans w. koch wrote:
> just to report another weirdness:
> if i
> 1. write those big numbers  (e.g. 8278095582780955) with [text set] to a [text define ] with [makefilename %.0f] (i used this to avoid unnecessary decimal points)
> 2. then write the textfile to disk as .txt
> 3. read it in again
> the symbols are automatically converted to exponential notation (8.2781e+15) inside the [text]/textfile, BUT retain their full precision!
>
> but in order for this to work, they have to be written to the [text] as symbols with [makefilename %.0f] first.
>
> weird, ain´t it?
>
> hans
>
>
>
>> Am 19.09.2020 um 10:49 schrieb hans w. koch <hansw.koch at gmail.com>:
>>
>> arrghhh…sometimes live can be so easy :-)
>>
>> cheers
>> hans
>>
>>> Am 19.09.2020 um 10:45 schrieb Lucas Cordiviola <lucarda27 at hotmail.com>:
>>>
>>> I think you can convert symbol back to float just using [f ].
>>>
>>> [123123123(
>>> |
>>> [makefilename %f]
>>> |
>>> [t a 0]
>>> |     |
>>> [text set foo]
>>>
>>>
>>>
>>> [0(
>>> |
>>> [text get foo]
>>> |
>>> [f ]
>>> |
>>> [print]
>>>
>>>
>>> :)
>>>
>>> Mensaje telepatico asistido por maquinas.
>>>
>>> On 9/19/2020 4:16 AM, hans w. koch wrote:
>>>> thanks lucas,
>>>>
>>>> transitioning numbers over to symbolland could solve my problem, interesting to know.
>>>>
>>>> i need to store some of the big numbers in a textfile and there i get the same problems with representation.
>>>> if i recall them later, they´ve lost their precision.
>>>> so i can make the transition back from symboldland with a bit of fudi objects voodoo and be good :-)
>>>>
>>>> what i use is this:
>>>> [makefilename %f]
>>>> |
>>>> [list trim symbol]
>>>> |
>>>> [fudiformat -u]
>>>> |
>>>> [fudiparse]
>>>>
>>>> and have my number back from symbol.
>>>>
>>>> best
>>>> hans
>>>>
>>>>
>>>>
>>>>> Am 19.09.2020 um 05:32 schrieb Lucas Cordiviola <lucarda27 at hotmail.com>:
>>>>>
>>>>> If you want to print the numbers nicely to the console add [makefilename %f] :
>>>>>
>>>>> [t b f]
>>>>>       |
>>>>>       [makefilename %f]
>>>>>       |
>>>>>       [print count]
>>>>>
>>>>>
>>>>> Be aware of https://github.com/pure-data/pure-data/issues/812
>>>>>
>>>>> :)
>>>>>
>>>>> Mensaje telepatico asistido por maquinas.
>>>>>
>>>>> On 9/18/2020 6:12 PM, hans w. koch wrote:
>>>>>> hello,
>>>>>>
>>>>>> its probably due to my lack of understanding the correct number representations, but here it goes anyway:
>>>>>>
>>>>>> i compiled pd 51-2 double precision for mac 10.14.6
>>>>>> with this version i was hoping to do some maths on big numbers.
>>>>>> but already an increment of 1 on some moderatly big number gives me problems of representation.
>>>>>>
>>>>>> i made a simple version of the problem as a patch.
>>>>>> to verify you have a working version of pd double, it contains a simple test.
>>>>>> and then an iterative addition +1 starting from 999999.
>>>>>> i get this:
>>>>>> count: 999999
>>>>>> count: 1e+06
>>>>>> count: 1e+06
>>>>>> count: 1e+06
>>>>>> count: 1e+06
>>>>>> count: 1e+06
>>>>>> count: 1.00000e+06
>>>>>> count: 1.00001e+06
>>>>>> count: 1.00001e+06
>>>>>> count: 1.00001e+06
>>>>>>
>>>>>> the algorith terminates succesfully by a [select] after 10 iterations, but the results don´t show what i expect.
>>>>>> this to me indicates, that the internal numbers are correct, but they don´t “surface” as such.
>>>>>>
>>>>>> i would be grateful for any pointers and possible workarounds, as the numbers i hope to be dealing with are potentially orders of magnitude higher.
>>>>>>
>>>>>> thanks hans
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Pd-list at lists.iem.at mailing list
>>>>>> UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list <https://lists.puredata.info/listinfo/pd-list>
-------------- next part --------------
#N canvas 213 65 898 584 12;
#X obj 330 289 text set bign;
#X obj 203 108 makefilename %.0f;
#X msg 360 263 0;
#X obj 496 414 text get bign;
#X msg 499 387 0;
#X obj 89 190 list fromsymbol;
#X obj 81 468 list tosymbol;
#X obj 86 288 text set bign;
#X obj 91 224 t l b;
#X msg 120 257 1;
#X obj 331 228 t a b;
#X obj 82 443 text get bign;
#X msg 82 418 1;
#X obj 83 490 print good;
#X obj 489 509 print bad;
#N canvas 0 50 985 489 other_tests_failed 0;
#X obj 78 325 array define bn 10;
#X obj 29 92 array set bn;
#X obj 211 148 array get bn;
#X obj 39 41 t l b;
#X msg 70 68 0;
#X floatatom 226 73 5 0 0 0 - - -;
#X obj 223 97 t f b;
#X msg 253 124 1;
#X msg 94 270 write bn.txt;
#X obj 218 224 print;
#X msg 94 298 read bn.txt;
#X obj 536 321 soundfiler;
#X msg 555 260 write -ascii -bytes 4 bnascii.txt bn;
#X msg 564 287 read bnascii.txt bn;
#X msg 40 14 1.23123e+008 4.56456e+008 7.8979e+008;
#X obj 210 178 makefilename %.0f;
#X text 523 161 this was tested with PR #855 "soundfile updates: refactor
\, bugfixes \, AIFC \, & CAF".;
#X connect 2 0 15 0;
#X connect 3 0 1 0;
#X connect 3 1 4 0;
#X connect 4 0 1 1;
#X connect 5 0 6 0;
#X connect 6 0 2 0;
#X connect 6 1 7 0;
#X connect 7 0 2 1;
#X connect 8 0 0 0;
#X connect 10 0 0 0;
#X connect 12 0 11 0;
#X connect 13 0 11 0;
#X connect 14 0 3 0;
#X connect 15 0 9 0;
#X restore 702 545 pd other_tests_failed;
#X obj 202 139 t b a a;
#X obj 204 83 pow 12;
#X msg 204 57 12;
#X obj 490 481 makefilename %.0f;
#X obj 623 98 text define -k bign;
#A set 8.9161e+012 \; 56 57 49 54 49 48 48 52 52 56 50 53 54 \;;
#X obj 352 505 print bad2;
#X obj 465 443 t a a;
#X text 246 56 1) store the number in text;
#X text 542 191 2) save the patch.;
#X text 550 211 3) close the patch and reopen it;
#X text 547 236 4) save again the patch;
#X text 556 264 5) close the patch and reopen it;
#X text 585 291 6) check this;
#X obj 689 294 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X obj 688 321 t b b;
#X text 494 131 this patch checks saving big numbers with the -k flag
;
#X text 26 8 this patch is for a Pd-double;
#X connect 1 0 16 0;
#X connect 2 0 0 1;
#X connect 3 0 22 0;
#X connect 4 0 3 0;
#X connect 5 0 8 0;
#X connect 6 0 13 0;
#X connect 8 0 7 0;
#X connect 8 1 9 0;
#X connect 9 0 7 1;
#X connect 10 0 0 0;
#X connect 10 1 2 0;
#X connect 11 0 6 0;
#X connect 12 0 11 0;
#X connect 16 1 5 0;
#X connect 16 2 10 0;
#X connect 17 0 1 0;
#X connect 18 0 17 0;
#X connect 19 0 14 0;
#X connect 22 0 21 0;
#X connect 22 1 19 0;
#X connect 29 0 30 0;
#X connect 30 0 12 0;
#X connect 30 1 4 0;


More information about the Pd-list mailing list