Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Possible Input for The numeral.js Format String
Floating point | ||
Number | Format String | Output |
10000 | '0,0.0000' | 10.000,0000 |
10000.23 | '0,0' | 10 |
-10000 | '0,0.0' | -10.000,0 |
-0.23 | '.00' | -,23 |
-0.23 | '(.00)' | (,23) |
0.23 | '0.00000' | 0,23000 |
0.23 | '0.0[0000]' | 0,23 |
1230974 | '0.0a' | 1,2m |
1460 | '0 a' | 1 k |
1 | '0o' | 1st |
Currency | ||
Number | Format String | Output |
1.000.234 | '$0,0.00' | $1.000,23 |
1000.2 | 0,0[.]00 $' | 1.000,20 $ |
1001 | '$ 0,0[.]00' | $ 1.001 |
Percentage | ||
Number | Format String | Output |
1 | '0%' | 100% |
-0.43 | '0 %' | -43% |
Possible Input for The Extended Number Format String
Percentages and absolute numbers are formatted separately. For this two format strings are used, which follow the same rules and structure. In general the strings of characters in the format string are simply replaced in the input number. Exceptions to this rule would be scaling factors and the number of decimal places.
The elements of the format string are separated by the "|" character. Format strings with less than 7 elements (or 6 "|" characters) are considered invalid and therefore ignored. In this case the standard format without scaling and with one position after the decimal point is used.
The format string consists of the following elements, the ordering is obligatory and cannot be changed:
Negative|Prefix|Thousands|Decimal|Scaling|PointsAfterDecimal|Suffix
Please note: given a "0" or a "1" will result in a scaling factor of 1. The only way to achieve a scaling by 10 is to set the input to "10^1".