Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

Possible Inputs 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%

Source 

 

Possible input for the Extended Number format string

Percentages and numbers are formatted separately. For this two format string 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 separate elements of the format string are separated by the "|" character. Format strings with less than 7 elements (i.e. 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


  
NegativeThe prefix for negative numbers. The string "()" will result in the number will be placed inside parentheses, including eventual prefixes and suffixes. If None is used the absolute number will be shown.
PrefixA prefixed string of characters, for example a currency symbol or an identifier for the scaling factor.
ThousandsA separator for thousands.
DecimalA separator for the decimal places.
ScalingThe scaling factor for the value. This can be given as a whole number or a power, formatted as n^m. A whole number will be calculated as a power to the basis 10 internally. In case of a given power the value will be divided by it directly. Even negative numbers are possible, for example "-3" or "10^-3"; in this case the value will get adequately higher. Non numeric inputs are ignored. 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 input "10^1".
PointsAfterDecimalThe number of places after the decimal.
Suffix

A suffix for the value, analogous to the prefix.

  • No labels