Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Formatting integers in strings

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114375] Formatting integers in strings
  • From: Dan <dflatin at rcn.com>
  • Date: Thu, 2 Dec 2010 05:41:37 -0500 (EST)

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: Macro processing in Mathematica
  • Next by Date: Re: Reduce::inex problem
  • Previous by thread: Macro processing in Mathematica
  • Next by thread: Re: Formatting integers in strings