2

I read the page about formatting PS Formatting, but my needs are a little different.

If I use numeric formatting for numbers bigger than 1000 I will always get something like this:

$x = 1000
"{0:N2}" -f $x
 = 1,000.00

But what I need is: 1000.00 since I can't work with commas here.

So how do I make this work?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
RayofCommand
  • 4,054
  • 17
  • 56
  • 92

2 Answers2

4

Don't use the N format specifier. Use F (fixed-point) instead:

C:\PS> "{0:F2}" -f 1000
1000.00

See this MSDN topic on all the standard .NET number format specifiers.

Keith Hill
  • 194,368
  • 42
  • 353
  • 369
  • The funny part is that it depends on system language. So for US it's for example 1000.86 and germany its 1000,86 using the same formatting. is there a formatting which switches to US? – RayofCommand Dec 09 '13 at 13:00
  • ahh found your other answer regarding this :) http://stackoverflow.com/questions/2379514/powershell-formatting-values-in-another-culture – RayofCommand Dec 09 '13 at 13:56
1

This should do what you need.

'{0:f2}' -f 1000
Rynant
  • 23,153
  • 5
  • 57
  • 71