MathGroup Archive 2010

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

Search the Archive

Re: Formatting integers in strings

  • To: mathgroup at
  • Subject: [mg114411] Re: Formatting integers in strings
  • From: David Annetts <david.annetts at>
  • Date: Fri, 3 Dec 2010 05:23:02 -0500 (EST)

IntegerString ...

On 2/12/2010 18:41, Dan wrote:
> I seem to be having a brain infarction and cannot see past this simple
> problem. I would like to be able to format a series of integers so
> that they are padded to the left with zeros as in:
> {000,030,060,090,120,150,180}
> Of course, I can write my own function to do this, but I want to use
> Mathematica's native formatting functionality.
> Here is my first try:
> NumberForm[Range[0,180,30],3,NumberPadding->{"0",""}]
> yielding:
> {0000,0030,0060,0090,0120,0150,0180}
> Making the obvious change:
> NumberForm[Range[0,180,30],2,NumberPadding->{"0",""}]
> yields:
> {000,030,060,090,0120,0150,0180}
> I have looked at the documentation for NumberForm and PaddedForm and
> there is no help there for this problem. Every example involves
> floating point numbers or integers that are not padded to the left. I
> am sure there is some simple concept that I am missing.

  • Prev by Date: Re: Font change of input & output cells
  • Next by Date: Re: Keep it real
  • Previous by thread: Re: Formatting integers in strings
  • Next by thread: Re: How to evaluate the Laplacian of a function as a