Forums > MaxMSP

fixed digits

October 22, 2008 | 1:04 pm

Hi there, quick question ..

I’d like my ints to be output with a set amount of digits, so that for
example 74 should always be output as a number with 6 digits like
000074 and 100 like 000100 and so on. I made a dirty fix with sprintf
but am wondering if there isn’t a more elegant way or preferably
object (or other trick that i might have overlooked) to do such a
thing ?

thanks !

g


October 22, 2008 | 1:21 pm

Don’t hesitate to post your fix. There are guys out there would could maybe
improve it.
J-F.

> Hi there, quick question ..
>
> I’d like my ints to be output with a set amount of digits, so that for
> example 74 should always be output as a number with 6 digits like
> 000074 and 100 like 000100 and so on. I made a dirty fix with sprintf
> but am wondering if there isn’t a more elegant way or preferably
> object (or other trick that i might have overlooked) to do such a
> thing ?
>
> thanks !
>
> g


October 22, 2008 | 1:30 pm


October 22, 2008 | 1:39 pm

On 22 oct. 08, at 15:04, Gideon Kiers wrote:
> I’d like my ints to be output with a set amount of digits, so that
> for example 74 should always be output as a number with 6 digits
> like 000074 and 100 like 000100 and so on. I made a dirty fix with
> sprintf but am wondering if there isn’t a more elegant way or
> preferably object (or other trick that i might have overlooked) to
> do such a thing ?

My good old rs.numbox does this nicely all in one object.
If you should happen to still use 4.6 on OSX feel free to grab it
here: http://arts.lu/roby/
Otherwise you have to wait for the Max 5 SDK to be released.

In the meantime the combine object with @padding might be helpful too.

Roby


October 22, 2008 | 2:46 pm


October 22, 2008 | 6:53 pm

I use the [sprintf] object with the "%.6d" argument where "6" is the number of digits you want your incoming number forced to:

– Pasted Max Patch, click to expand. –

October 23, 2008 | 8:52 am

excellent, merci !

On 22 okt 2008, at 20:53, Dave Raybould wrote:

> I use the [sprintf] object with the "%.6d" argument where "6" is the
> number of digits you want your incoming number forced to


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