How can I format powershell output for decimal without a comma? I am using '{0:N2}' -f $a but I don't want the comma for the thousands.
There are a plethora of different format strings. In your case I would suggest:
'{0:d2}' -f $a
A good reference is String Formatting in C#
Actually here are some examples:
$a = 124000.4201
'{0:g2}' -f $a
1.2e+05
'{0:f2}' -f $a
124000.42
# and since it is using the .net formatter for all this after all
'{0:00.0000}' -f $a
124000.4201
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With