You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/api/currency/currency-formatter.md
+34-3Lines changed: 34 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,8 @@ Number to be formatted, eg. `9.99`.
20
20
21
21
### Example
22
22
23
+
#### Static Formatter
24
+
23
25
Prior to using any currency methods, you must load `cldr/main/{locale}/currencies.json`, `cldr/supplemental/currencyData.json`, and the CLDR content required by the number module. If using plural messages, you also must load the CLDR content required by the plural module. Read [CLDR content][] if you need more information.
24
26
25
27
[CLDR content]: ../../../README.md#2-cldr-content
@@ -37,6 +39,8 @@ formatter( 9.99 );
37
39
38
40
```
39
41
42
+
#### Instance Formatter
43
+
40
44
You can use the instance method `.currencyFormatter()`, which uses the instance locale.
41
45
42
46
```javascript
@@ -62,6 +66,8 @@ For comparison, follow the formatting output of different symbols in different l
Copy file name to clipboardExpand all lines: doc/api/number/number-formatter.md
+13-6Lines changed: 13 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -149,15 +149,11 @@ Long numbers can be represented in a compact format, with `short` using abbrevia
149
149
150
150
```javascript
151
151
var shortFormatter =Globalize( "en" ).numberFormatter({
152
-
compact:"short",
153
-
maximumFractionDigits:0,
154
-
style:"decimal"
152
+
compact:"short"
155
153
});
156
154
157
155
var longFormatter =Globalize( "en" ).numberFormatter({
158
-
compact:"long",
159
-
maximumFractionDigits:0,
160
-
style:"decimal"
156
+
compact:"long"
161
157
});
162
158
163
159
shortFormatter( 27588910 );
@@ -167,6 +163,17 @@ longFormatter( 27588910 );
167
163
// > "28 million"
168
164
```
169
165
166
+
The minimumSignificantDigits and maximumSignificantDigits options are specially useful to control the number of digits to display.
167
+
168
+
```js
169
+
Globalize( "en" ).formatNumber( 27588910, {
170
+
compact:"short",
171
+
minimumSignificantDigits:3,
172
+
maximumSignificantDigits:3
173
+
});
174
+
// > "27.6M"
175
+
```
176
+
170
177
#### Configuring Rounding
171
178
172
179
Numbers with a decreased amount of decimal places can be rounded up, rounded down, rounded arithmetically, or truncated by setting the `round` option to `ceil`, `floor`, `round` (default), or `truncate`.
0 commit comments