Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell Decimal Format without comma

Tags:

powershell

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.

like image 595
Walinmichi Avatar asked Sep 08 '25 01:09

Walinmichi


1 Answers

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
like image 66
EBGreen Avatar answered Sep 09 '25 15:09

EBGreen