MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Number to string headed by zeros

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110307] Re: Number to string headed by zeros
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Sun, 13 Jun 2010 04:08:25 -0400 (EDT)

On 6/12/10 at 5:32 AM, rui.rojo at gmail.com (Rui) wrote:

>I need to create strings out of integers, padding them with zeros,
>cause otherwise they end up sorted in the wrong order. "10.gif"
>before "1.gif". For now I'm gonna do it by adding 1000, converting
>to string, and taking the heading 1, but I'm sure there are better
>options.

In[1]:= (ToString@PaddedForm[#, 2, NumberPadding -> {"0", ""}] <>
     ".gif") & /@ Range[5]

Out[1]= {001.gif,002.gif,003.gif,004.gif,005.gif}

or you could use NumberForm instead of PaddedForm



  • Prev by Date: Re: Number to string headed by zeros
  • Next by Date: Re: Automatic update of variables
  • Previous by thread: Re: Number to string headed by zeros
  • Next by thread: Re: Number to string headed by zeros