Forums > MaxMSP

how to break a very long int into a list

February 20, 2007 | 4:58 am

Hi list,

Can’t seem to figure out how to do this – I’m sure there’s some easy way.

I need to insert a space between each digit of a very long int.

Sending an int into an atoi object works fine with ints < = ten digits long. After that it starts doing strange things that I don't understand. My number is much longer than 10 digits, so that doesn't seem to be the way to go.

Any help would be greatly appreciated.


February 20, 2007 | 6:03 am

I think one problem you might run into is that the largest int you can have is 2147483647 (others on this list are better versed in this that I am). Larger #’s will be "adjusted" to fall within the range of +/- 2147483647 (again…others can certainly speak with more authority on this than I can…so apologies if not 100% accurate). If somehow this list of #’s were stored as a string instead, e.g."123451234512345", you could use regexp.

David

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 180 138 22 196617 set;
#P message 90 181 155 196617 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5;
#P newex 90 138 62 196617 prepend set;
#P message 62 51 110 196617 "123451234512345";
#P newex 62 103 66 196617 regexp \\d;
#P connect 0 2 2 0;
#P connect 2 0 3 0;
#P fasten 4 0 3 0 185 167 95 167;
#P connect 1 0 0 0;
#P window clipboard copycount 5;


February 20, 2007 | 7:00 am

Zachary Seldess wrote:
> I need to insert a space between each digit of a very long int.
>
> Sending an int into an atoi object works fine with ints < = ten digits
> long. After that it starts doing strange things that I don’t
> understand. My number is much longer than 10 digits, so that doesn’t
> seem to be the way to go.

You would need to make sure, that you send it always as symbol. Elsewise
its interpreted as integer number which has a limit according to
32-bits. which would turn some numbers into negative numbers and such.
Always surround the number with quotes and then send it to atoi…

Stefan

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 126 247 65 196617 fromsymbol;
#P newex 126 153 47 196617 route 34;
#P newex 126 224 39 196617 itoa;
#P newex 104 86 32 196617 t b l;
#P newex 126 176 47 196617 t 32 i;
#P newex 126 130 39 196617 iter;
#P newex 126 202 48 196617 zl group;
#P message 126 291 252 196617 1 2 3 4 5 6 7 8 9 2 2 2;
#P newex 126 270 62 196617 prepend set;
#P newex 126 107 39 196617 atoi;
#P message 104 65 110 196617 "123456789222";
#P comment 183 154 156 196617 < - to get rid of the quotes....;
#P connect 1 0 8 0;
#P fasten 8 0 5 0 109 198 131 198;
#P connect 8 1 2 0;
#P connect 11 0 3 0;
#P connect 9 0 11 0;
#P connect 10 1 7 0;
#P connect 6 0 10 0;
#P connect 7 1 5 0;
#P connect 5 0 9 0;
#P connect 7 0 5 0;
#P connect 2 0 6 0;
#P connect 3 0 4 0;
#P window clipboard copycount 12;


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com


February 20, 2007 | 10:58 am

If we could get OpenDragon to port their V objects to UB, Vencode 10 10 10
10 ….would break the number into individual digits. Writing things to the
text object causes spaces between characters – usually a nuisance.

On 2/19/07 11:58 PM, "Zachary Seldess" wrote:

>
> Hi list,
>
> Can’t seem to figure out how to do this – I’m sure there’s some easy way.
>
> I need to insert a space between each digit of a very long int.
>
> Sending an int into an atoi object works fine with ints < = ten digits long.
> After that it starts doing strange things that I don’t understand. My number
> is much longer than 10 digits, so that doesn’t seem to be the way to go.
>
> Any help would be greatly appreciated.
> –
> http://www.zacharyseldess.com
> http://www.newmedialab.cuny.edu/projects
> http://www.intermediaartsgroup.com

Cheers
Gary Lee Nelson
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson


February 20, 2007 | 7:35 pm

Thanks everyone for the help. It seems that sending the number to atoi as a symbol DOES work, but only up to a certain size (something like 120 digits – I remember some similar limit with lists when working with coll, etc.). So it’s still not my solution. I now have a javascript solution though.


Viewing 5 posts - 1 through 5 (of 5 total)