Forums > MaxMSP

Separate a long number into smaller numbers

March 4, 2011 | 12:00 am

Hi there
I’m trying to figure out a way to split up a long number like 606569 into 60 65 69
I figured it would be a simple task but I’ve spent hours looking around the forum to no avail.
I’ve been looking at the regexp object, but I really dont understand the syntax for it so I’m not getting the right result :S
Pretty sure this will be an easy one for someone.
Thanks
Lee



o s
March 4, 2011 | 1:05 am

hth

o

– Pasted Max Patch, click to expand. –


MIB
March 4, 2011 | 4:02 am

since regexp gives me nightmares as well (I really ought to learn it one of these days) here is a more Max "friendly" way… sure there are better ones out there.

– Pasted Max Patch, click to expand. –

March 4, 2011 | 10:52 am

Thanks so much guys! Both these ways work perfectly.
Lee


March 4, 2011 | 1:30 pm

And here’s a way with arithmetic operators only. Modulo is your friend.

All of the solutions shown have issues with negative values. All also have the possible issue that the two-digit results drop leading zeros. Both of these issues left as an exercise for the reader.

– Pasted Max Patch, click to expand. –

March 6, 2011 | 11:34 am

Oops… wanted to take a look at the first example before posting mine, then lost track of what was on the clipboard. So now I have to recreate the patch. Easily enough done…

– Pasted Max Patch, click to expand. –

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