Numbers
- Last UpdatedJul 13, 2023
- 1 minute read
The following table lists the basic number formatting.
|
Identifier |
Type |
Format |
Example Output |
Example Output for "-12400" |
|---|---|---|---|---|
|
c |
Currency |
{0:c} |
$1.42 |
-$12,400 |
|
d |
Decimal (whole number) |
{0:d} |
Error |
-12400 |
|
e |
Scientific |
{0:e} |
1.420000e+000 |
-1.240000e+004 |
|
f |
Fixed point |
{0:f} |
1.42 |
-12400.00 |
|
g |
General |
{0:g} |
1.42 |
-12400 |
|
n |
Number with commas for thousands |
{0:n} |
1.42 |
-12,400 |
|
r |
Round trip |
{0:r} |
1.42 |
Error |
|
x |
Hexadecimal |
{0:x4} |
Error |
cf90 |
The following table lists the custom number formatting.
|
Identifier |
Type |
Format |
Example Output |
Notes |
|---|---|---|---|---|
|
0 |
Zero placeholder |
{0:00.0000} |
1500.4200 |
Pads with zeroes. |
|
# |
Digit placeholder |
{0:(#).##} |
(1500).42 |
|
|
. |
Decimal point |
{0:0.0} |
1500.4 |
|
|
, |
Thousand separator |
{0:0,0} |
1,500 |
Must be between two zeroes. |
|
,. |
Number scaling |
{0:0,.} |
2 |
Comma adjacent to Period scales by 1000. |
|
% |
Percent |
{0:0%} |
150042% |
Multiplies by 100, adds % sign. |
|
e |
Exponent placeholder |
{0:00e+0} |
15e+2 |
Many exponent formats available. |
|
; |
Group separator |
Used to separate multiple formats in one string format (for example, including parentheses around a string if the value is negative; see Format String Examples). |