Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

RE: question of formatting with PaddedForm

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28566] RE: [mg28556] question of formatting with PaddedForm
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.de>
  • Date: Sat, 28 Apr 2001 21:35:55 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

> -----Original Message-----
> From: jabauer at oanet.com [mailto:jabauer at oanet.com]
To: mathgroup at smc.vnet.net
> Sent: Friday, April 27, 2001 9:56 AM
> To: mathgroup at smc.vnet.net
> Subject: [mg28566] [mg28556] question of formatting with PaddedForm
> 

> I am having some difficulties getting a formatted output to 
> look like I
> 'think' it should look. What I want looks like this (three 
> digits, padded
> with leading zeros for numbers less than 100):
> 
> 098
> 099
> 100
> 101
> 102
> 103
> 104
> 105
> 
> 
> But, when I try this:
> 
> For[i = 98, i <= 105,
>   Print[PaddedForm[i, 2, NumberPadding -> {"0", "0"},
> SignPadding ->
> False]];
>   i++]
> 
> 
> I get this:
> 
> 098
> 099
> 0100
> 0101
> 0102
> 0103
> 0104
> 0105
> 
> 
> I only want three digits, not the extra leading zero for 
> values >= 100. 

Jim, try 

For[i = 98, i <= 105, 
  Print[PaddedForm[i, 3, NumberPadding -> {"0", "0"}, 
      NumberSigns -> {"-", " "}, SignPadding -> True]];
  i++]

For[i = 98, i <= 105, 
  Print[PaddedForm[i, 3, NumberPadding -> {"0", "0"}, 
      NumberSigns -> {"", ""}]];
  i++]

one or the other should do. To better understand the options
for PaddedForm also look at

For[i = 98, i <= 105, 
  Print[PaddedForm[i, 3, NumberPadding -> {"0", "0"}, 
      NumberSigns -> {"-", "+"}, SignPadding -> False]];
  i++]

For[i = 98, i <= 105, 
  Print[PaddedForm[i, 3, NumberPadding -> {" ", " "}, 
      NumberSigns -> {"-", "+"}, SignPadding -> True]];
  i++]

-- Hartmut Wolf



  • Prev by Date: Re: question of formatting with PaddedForm
  • Next by Date: Re: Interior of a polygon
  • Previous by thread: Re: question of formatting with PaddedForm
  • Next by thread: Re: How can I force ListPlot to show all data in graphics?