fixed digits

Oct 22, 2008 at 1:04pm

fixed digits

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

#40462
Oct 22, 2008 at 1:21pm

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

#143227
Oct 22, 2008 at 1:30pm

#143228
Oct 22, 2008 at 1:39pm

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

#143229
Oct 22, 2008 at 2:46pm

#143230
Oct 22, 2008 at 6:53pm

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. –
#143231
Oct 23, 2008 at 8:52am

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

#143232

You must be logged in to reply to this topic.