[PD] Converting decimal to binary digits

Marc Lavallée marc at hacklava.net
Tue Aug 23 00:45:56 CEST 2005


(this is my second attempt at sending this message; I suspect there was a 
problem with my smtp gateway, so please ignore if it's a duplicate.)

Le 22 Août 2005 15:14, algodon a écrit :
> Hi !
>
> This may be an obvious question but i don't know how to do it in PD. I
> need to build a patch that would convert decimal to binary digits. I
> would enter 13 and it would render "1101" or 9 would give "1001".
>
> Thank you

Here's an abstraction to extract the value of a specific bit,
along with an example to decode a byte. 
That's not exactly what you are looking for, but it's a good start.

Bonne soirée.
--
Marc
-------------- next part --------------
#N canvas 109 86 315 214 10;
#X obj 52 161 outlet;
#X obj 109 93 \$1;
#X obj 52 69 inlet;
#X obj 109 69 loadbang;
#X obj 52 92 >>;
#X obj 52 115 % 2;
#X text 30 20 value of a specific bit \;;
#X text 30 36 argument: bit position;
#X obj 52 138 change;
#X text 30 6 abstraction to extract the;
#X connect 1 0 4 1;
#X connect 2 0 4 0;
#X connect 3 0 1 0;
#X connect 4 0 5 0;
#X connect 5 0 8 0;
#X connect 8 0 0 0;
-------------- next part --------------
#N canvas 383 189 405 236 10;
#X obj 331 153 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1
1;
#X obj 289 153 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1
1;
#X obj 248 153 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
#X obj 206 153 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1
1;
#X obj 164 153 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
#X obj 122 153 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1
1;
#X obj 81 153 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 -1
;
#X obj 39 153 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 -1
;
#X obj 103 89 t f f f f f f f f;
#X floatatom 103 62 5 0 0 0 - - -;
#X obj 39 130 bit 7;
#X obj 331 130 bit 0;
#X obj 289 130 bit 1;
#X obj 248 130 bit 2;
#X obj 206 130 bit 3;
#X obj 164 130 bit 4;
#X obj 122 130 bit 5;
#X obj 81 130 bit 6;
#X text 52 20 decoding a byte;
#X connect 8 0 10 0;
#X connect 8 1 17 0;
#X connect 8 2 16 0;
#X connect 8 3 15 0;
#X connect 8 4 14 0;
#X connect 8 5 13 0;
#X connect 8 6 12 0;
#X connect 8 7 11 0;
#X connect 9 0 8 0;
#X connect 10 0 7 0;
#X connect 11 0 0 0;
#X connect 12 0 1 0;
#X connect 13 0 2 0;
#X connect 14 0 3 0;
#X connect 15 0 4 0;
#X connect 16 0 5 0;
#X connect 17 0 6 0;


More information about the Pd-list mailing list