xref: /aosp_15_r20/external/cldr/docs/ldml/tr35-numbers.md (revision 912701f9769bb47905792267661f0baf2b85bed5)
1*912701f9SAndroid Build Coastguard Worker## Unicode Technical Standard #35
2*912701f9SAndroid Build Coastguard Worker
3*912701f9SAndroid Build Coastguard Worker# Unicode Locale Data Markup Language (LDML)<br/>Part 3: Numbers
4*912701f9SAndroid Build Coastguard Worker
5*912701f9SAndroid Build Coastguard Worker|Version|45        |
6*912701f9SAndroid Build Coastguard Worker|-------|----------|
7*912701f9SAndroid Build Coastguard Worker|Editors|Shane F. Carr (<a href="mailto:[email protected]">[email protected]</a>) and <a href="tr35.md#Acknowledgments">other CLDR committee members|
8*912701f9SAndroid Build Coastguard Worker
9*912701f9SAndroid Build Coastguard WorkerFor the full header, summary, and status, see [Part 1: Core](tr35.md).
10*912701f9SAndroid Build Coastguard Worker
11*912701f9SAndroid Build Coastguard Worker### _Summary_
12*912701f9SAndroid Build Coastguard Worker
13*912701f9SAndroid Build Coastguard WorkerThis document describes parts of an XML format (_vocabulary_) for the exchange of structured locale data. This format is used in the [Unicode Common Locale Data Repository](https://www.unicode.org/cldr/).
14*912701f9SAndroid Build Coastguard Worker
15*912701f9SAndroid Build Coastguard WorkerThis is a partial document, describing only those parts of the LDML that are relevant for number and currency formatting. For the other parts of the LDML see the [main LDML document](tr35.md) and the links above.
16*912701f9SAndroid Build Coastguard Worker
17*912701f9SAndroid Build Coastguard Worker### _Status_
18*912701f9SAndroid Build Coastguard Worker
19*912701f9SAndroid Build Coastguard Worker<!-- _This is a draft document which may be updated, replaced, or superseded by other documents at any time.
20*912701f9SAndroid Build Coastguard WorkerPublication does not imply endorsement by the Unicode Consortium.
21*912701f9SAndroid Build Coastguard WorkerThis is not a stable document; it is inappropriate to cite this document as other than a work in progress._ -->
22*912701f9SAndroid Build Coastguard Worker
23*912701f9SAndroid Build Coastguard Worker_This document has been reviewed by Unicode members and other interested parties, and has been approved for publication by the Unicode Consortium.
24*912701f9SAndroid Build Coastguard WorkerThis is a stable document and may be used as reference material or cited as a normative reference by other specifications._
25*912701f9SAndroid Build Coastguard Worker
26*912701f9SAndroid Build Coastguard Worker> _**A Unicode Technical Standard (UTS)** is an independent specification. Conformance to the Unicode Standard does not imply conformance to any UTS._
27*912701f9SAndroid Build Coastguard Worker
28*912701f9SAndroid Build Coastguard Worker_Please submit corrigenda and other comments with the CLDR bug reporting form [[Bugs](tr35.md#Bugs)]. Related information that is useful in understanding this document is found in the [References](tr35.md#References). For the latest version of the Unicode Standard see [[Unicode](tr35.md#Unicode)]. For a list of current Unicode Technical Reports see [[Reports](tr35.md#Reports)]. For more information about versions of the Unicode Standard, see [[Versions](tr35.md#Versions)]._
29*912701f9SAndroid Build Coastguard Worker
30*912701f9SAndroid Build Coastguard Worker## <a name="Parts" href="#Parts">Parts</a>
31*912701f9SAndroid Build Coastguard Worker
32*912701f9SAndroid Build Coastguard WorkerThe LDML specification is divided into the following parts:
33*912701f9SAndroid Build Coastguard Worker
34*912701f9SAndroid Build Coastguard Worker*   Part 1: [Core](tr35.md#Contents) (languages, locales, basic structure)
35*912701f9SAndroid Build Coastguard Worker*   Part 2: [General](tr35-general.md#Contents) (display names & transforms, etc.)
36*912701f9SAndroid Build Coastguard Worker*   Part 3: [Numbers](tr35-numbers.md#Contents) (number & currency formatting)
37*912701f9SAndroid Build Coastguard Worker*   Part 4: [Dates](tr35-dates.md#Contents) (date, time, time zone formatting)
38*912701f9SAndroid Build Coastguard Worker*   Part 5: [Collation](tr35-collation.md#Contents) (sorting, searching, grouping)
39*912701f9SAndroid Build Coastguard Worker*   Part 6: [Supplemental](tr35-info.md#Contents) (supplemental data)
40*912701f9SAndroid Build Coastguard Worker*   Part 7: [Keyboards](tr35-keyboards.md#Contents) (keyboard mappings)
41*912701f9SAndroid Build Coastguard Worker*   Part 8: [Person Names](tr35-personNames.md#Contents) (person names)
42*912701f9SAndroid Build Coastguard Worker*   Part 9: [MessageFormat](tr35-messageFormat.md#Contents) (message format)
43*912701f9SAndroid Build Coastguard Worker
44*912701f9SAndroid Build Coastguard Worker## <a name="Contents" href="#Contents">Contents of Part 3, Numbers</a>
45*912701f9SAndroid Build Coastguard Worker
46*912701f9SAndroid Build Coastguard Worker* [Numbering Systems](#Numbering_Systems)
47*912701f9SAndroid Build Coastguard Worker* [Number Elements](#Number_Elements)
48*912701f9SAndroid Build Coastguard Worker  * [Default Numbering System](#defaultNumberingSystem)
49*912701f9SAndroid Build Coastguard Worker  * [Other Numbering Systems](#otherNumberingSystems)
50*912701f9SAndroid Build Coastguard Worker  * [Number Symbols](#Number_Symbols)
51*912701f9SAndroid Build Coastguard Worker  * [Number Formats](#Number_Formats)
52*912701f9SAndroid Build Coastguard Worker    * [Compact Number Formats](#Compact_Number_Formats)
53*912701f9SAndroid Build Coastguard Worker    * [Currency Formats](#Currency_Formats)
54*912701f9SAndroid Build Coastguard Worker  * [Miscellaneous Patterns](#Miscellaneous_Patterns)
55*912701f9SAndroid Build Coastguard Worker  * [Minimal Pairs](#Minimal_Pairs)
56*912701f9SAndroid Build Coastguard Worker* [Number Format Patterns](#Number_Format_Patterns)
57*912701f9SAndroid Build Coastguard Worker  * [Number Patterns](#Number_Patterns)
58*912701f9SAndroid Build Coastguard Worker    * Table: [Number Pattern Examples](#Number_Pattern_Examples)
59*912701f9SAndroid Build Coastguard Worker  * [Special Pattern Characters](#Special_Pattern_Characters)
60*912701f9SAndroid Build Coastguard Worker    * Table: [Number Pattern Character Definitions](#Number_Pattern_Character_Definitions)
61*912701f9SAndroid Build Coastguard Worker    * Table: [Sample Patterns and Results](#Sample_Patterns_and_Results)
62*912701f9SAndroid Build Coastguard Worker    * [Explicit Plus Signs](#Explicit_Plus)
63*912701f9SAndroid Build Coastguard Worker  * [Formatting](#Formatting)
64*912701f9SAndroid Build Coastguard Worker  * [Scientific Notation](#sci)
65*912701f9SAndroid Build Coastguard Worker  * [Significant Digits](#sigdig)
66*912701f9SAndroid Build Coastguard Worker    * Table: [Significant Digits Examples](#Significant_Digits_Examples)
67*912701f9SAndroid Build Coastguard Worker  * [Padding](#Padding)
68*912701f9SAndroid Build Coastguard Worker  * [Rounding](#Rounding)
69*912701f9SAndroid Build Coastguard Worker  * [Quoting Rules](#Quoting_Rules)
70*912701f9SAndroid Build Coastguard Worker* [Currencies](#Currencies)
71*912701f9SAndroid Build Coastguard Worker  * [Supplemental Currency Data](#Supplemental_Currency_Data)
72*912701f9SAndroid Build Coastguard Worker* [Language Plural Rules](#Language_Plural_Rules)
73*912701f9SAndroid Build Coastguard Worker  * [Explicit 0 and 1 rules](#Explicit_0_1_rules)
74*912701f9SAndroid Build Coastguard Worker  * [Plural rules syntax](#Plural_rules_syntax)
75*912701f9SAndroid Build Coastguard Worker    * [Operands](#Operands)
76*912701f9SAndroid Build Coastguard Worker      * Table: [Plural Operand Meanings](#Plural_Operand_Meanings)
77*912701f9SAndroid Build Coastguard Worker      * Table: [Plural Operand Examples](#Plural_Operand_Examples)
78*912701f9SAndroid Build Coastguard Worker    * [Relations](#Relations)
79*912701f9SAndroid Build Coastguard Worker      * Table: [Relations Examples](#Relations_Examples)
80*912701f9SAndroid Build Coastguard Worker      * Table: [Plural Rules Examples](#Plural_Rules_Examples)
81*912701f9SAndroid Build Coastguard Worker    * [Samples](#Samples)
82*912701f9SAndroid Build Coastguard Worker      * Table: [Plural Samples Examples](#Plural_Samples_Examples)
83*912701f9SAndroid Build Coastguard Worker    * [Using Cardinals](#Using_cardinals)
84*912701f9SAndroid Build Coastguard Worker  * [Plural Ranges](#Plural_Ranges)
85*912701f9SAndroid Build Coastguard Worker* [Rule-Based Number Formatting](#Rule-Based_Number_Formatting)
86*912701f9SAndroid Build Coastguard Worker* [Parsing Numbers](#Parsing_Numbers)
87*912701f9SAndroid Build Coastguard Worker* [Number Range Formatting](#Number_Range_Formatting)
88*912701f9SAndroid Build Coastguard Worker  * [Approximate Number Formatting](#Approximate_Number_Formatting)
89*912701f9SAndroid Build Coastguard Worker  * [Collapsing Number Ranges](#Collapsing_Number_Ranges)
90*912701f9SAndroid Build Coastguard Worker  * [Range Pattern Processing](#Range_Pattern_Processing)
91*912701f9SAndroid Build Coastguard Worker
92*912701f9SAndroid Build Coastguard Worker## <a name="Numbering_Systems" href="#Numbering_Systems">Numbering Systems</a>
93*912701f9SAndroid Build Coastguard Worker
94*912701f9SAndroid Build Coastguard Worker```xml
95*912701f9SAndroid Build Coastguard Worker<!ELEMENT numberingSystems ( numberingSystem* ) >
96*912701f9SAndroid Build Coastguard Worker<!ELEMENT numberingSystem EMPTY >
97*912701f9SAndroid Build Coastguard Worker<!ATTLIST numberingSystem id NMTOKEN #REQUIRED >
98*912701f9SAndroid Build Coastguard Worker<!ATTLIST numberingSystem type ( numeric | algorithmic ) #REQUIRED >
99*912701f9SAndroid Build Coastguard Worker<!ATTLIST numberingSystem radix NMTOKEN #IMPLIED >
100*912701f9SAndroid Build Coastguard Worker<!ATTLIST numberingSystem digits CDATA #IMPLIED >
101*912701f9SAndroid Build Coastguard Worker<!ATTLIST numberingSystem rules CDATA #IMPLIED >
102*912701f9SAndroid Build Coastguard Worker```
103*912701f9SAndroid Build Coastguard Worker
104*912701f9SAndroid Build Coastguard WorkerNumbering systems information is used to define different representations for numeric values to an end user. Numbering systems are defined in CLDR as one of two different types: algorithmic and numeric. Numeric systems are simply a decimal based system that uses a predefined set of digits to represent numbers. Examples are Western digits (ASCII digits), Thai digits, Devanagari digits. Algorithmic systems are more complex in nature, since the proper formatting and presentation of a numeric quantity is based on some algorithm or set of rules. Examples are Chinese numerals, Hebrew numerals, or Roman numerals. In CLDR, the rules for presentation of numbers in an algorithmic system are defined using the RBNF syntax described in _[Section 6: Rule-Based Number Formatting](#Rule-Based_Number_Formatting)_.
105*912701f9SAndroid Build Coastguard Worker
106*912701f9SAndroid Build Coastguard WorkerAttributes for the `<numberingSystem>` element are as follows:
107*912701f9SAndroid Build Coastguard Worker
108*912701f9SAndroid Build Coastguard Worker- `id` - Specifies the name of the numbering system that can be used to designate its use in formatting.
109*912701f9SAndroid Build Coastguard Worker- `type` - Specifies whether the numbering system is algorithmic or numeric.
110*912701f9SAndroid Build Coastguard Worker- `digits` - For numeric systems, specifies the digits used to represent numbers, in order, starting from zero.
111*912701f9SAndroid Build Coastguard Worker- `rules` - Specifies the RBNF ruleset to be used for formatting numbers from this numbering system. The rules specifier can contain simply a ruleset name, in which case the ruleset is assumed to be found in the rule set grouping "NumberingSystemRules". Alternatively, the specifier can denote a specific locale, ruleset grouping, and ruleset name, separated by slashes.
112*912701f9SAndroid Build Coastguard Worker
113*912701f9SAndroid Build Coastguard WorkerExamples:
114*912701f9SAndroid Build Coastguard Worker
115*912701f9SAndroid Build Coastguard Worker```xml
116*912701f9SAndroid Build Coastguard Worker<!-- ASCII digits - A numeric system -->
117*912701f9SAndroid Build Coastguard Worker<numberingSystem id="latn" type="numeric" digits="0123456789"/>
118*912701f9SAndroid Build Coastguard Worker
119*912701f9SAndroid Build Coastguard Worker<!-- A numeric system using Thai digits -->
120*912701f9SAndroid Build Coastguard Worker<numberingSystem id="thai" type="numeric" digits="๐๑๒๓๔๕๖๗๘๙"/>
121*912701f9SAndroid Build Coastguard Worker
122*912701f9SAndroid Build Coastguard Worker<!-- An algorithmic system - Georgian numerals, rules found in NumberingSystemRules -->
123*912701f9SAndroid Build Coastguard Worker<numberingSystem id="geor" type="algorithmic" rules="georgian"/>
124*912701f9SAndroid Build Coastguard Worker
125*912701f9SAndroid Build Coastguard Worker<!-- An algorithmic system. Traditional Chinese numerals -->
126*912701f9SAndroid Build Coastguard Worker<numberingSystem id="hant" type="algorithmic" rules="zh_Hant/SpelloutRules/spellout-cardinal"/>
127*912701f9SAndroid Build Coastguard Worker```
128*912701f9SAndroid Build Coastguard Worker
129*912701f9SAndroid Build Coastguard WorkerFor general information about the numbering system data, including the BCP47 identifiers, see the main document _Section Q.1.1 [Numbering System Data](tr35.md#Numbering%20System%20Data)._
130*912701f9SAndroid Build Coastguard Worker
131*912701f9SAndroid Build Coastguard Worker## <a name="Number_Elements" href="#Number_Elements">Number Elements</a>
132*912701f9SAndroid Build Coastguard Worker
133*912701f9SAndroid Build Coastguard Worker```xml
134*912701f9SAndroid Build Coastguard Worker<!ELEMENT numbers ( alias | ( defaultNumberingSystem*, otherNumberingSystems*, minimumGroupingDigits*, symbols*, decimalFormats*, scientificFormats*, percentFormats*, currencyFormats*, currencies?, miscPatterns*, minimalPairs*, special* ) ) >
135*912701f9SAndroid Build Coastguard Worker```
136*912701f9SAndroid Build Coastguard Worker
137*912701f9SAndroid Build Coastguard WorkerThe numbers element supplies information for formatting and parsing numbers and currencies. It has the following sub-elements: `<defaultNumberingSystem>`, `<otherNumberingSystems>`, `<symbols>`, `<decimalFormats>`, `<scientificFormats>`, `<percentFormats>`, `<currencyFormats>`, and `<currencies>`. The currency IDs are from [[ISO4217](tr35.md#ISO4217)] (plus some additional common-use codes). For more information, including the pattern structure, see _[Section 3: Number Format Patterns](#Number_Format_Patterns)_.
138*912701f9SAndroid Build Coastguard Worker
139*912701f9SAndroid Build Coastguard Worker### <a name="defaultNumberingSystem" href="#defaultNumberingSystem">Default Numbering System</a>
140*912701f9SAndroid Build Coastguard Worker
141*912701f9SAndroid Build Coastguard Worker```xml
142*912701f9SAndroid Build Coastguard Worker<!ELEMENT defaultNumberingSystem ( #PCDATA )>
143*912701f9SAndroid Build Coastguard Worker```
144*912701f9SAndroid Build Coastguard Worker
145*912701f9SAndroid Build Coastguard WorkerThis element indicates which numbering system should be used for presentation of numeric quantities in the given locale.
146*912701f9SAndroid Build Coastguard Worker
147*912701f9SAndroid Build Coastguard Worker### <a name="otherNumberingSystems" href="#otherNumberingSystems">Other Numbering Systems</a>
148*912701f9SAndroid Build Coastguard Worker
149*912701f9SAndroid Build Coastguard Worker```xml
150*912701f9SAndroid Build Coastguard Worker<!ELEMENT otherNumberingSystems ( alias | ( native*, traditional*, finance*)) >
151*912701f9SAndroid Build Coastguard Worker```
152*912701f9SAndroid Build Coastguard Worker
153*912701f9SAndroid Build Coastguard WorkerThis element defines general categories of numbering systems that are sometimes used in the given locale for formatting numeric quantities. These additional numbering systems are often used in very specific contexts, such as in calendars or for financial purposes. There are currently three defined categories, as follows:
154*912701f9SAndroid Build Coastguard Worker
155*912701f9SAndroid Build Coastguard Worker**native**
156*912701f9SAndroid Build Coastguard Worker
157*912701f9SAndroid Build Coastguard Worker> Defines the numbering system used for the native digits, usually defined as a part of the script used to write the language. The native numbering system can only be a numeric positional decimal-digit numbering system, using digits with General_Category=Decimal_Number. Note: In locales where the native numbering system is the default, it is assumed that the numbering system "latn" (Western digits 0-9) is always acceptable, and can be selected using the -nu keyword as part of a Unicode locale identifier.
158*912701f9SAndroid Build Coastguard Worker
159*912701f9SAndroid Build Coastguard Worker**traditional**
160*912701f9SAndroid Build Coastguard Worker
161*912701f9SAndroid Build Coastguard Worker> Defines the traditional numerals for a locale. This numbering system may be numeric or algorithmic. If the traditional numbering system is not defined, applications should use the native numbering system as a fallback.
162*912701f9SAndroid Build Coastguard Worker
163*912701f9SAndroid Build Coastguard Worker**finance**
164*912701f9SAndroid Build Coastguard Worker
165*912701f9SAndroid Build Coastguard Worker> Defines the numbering system used for financial quantities. This numbering system may be numeric or algorithmic. This is often used for ideographic languages such as Chinese, where it would be easy to alter an amount represented in the default numbering system simply by adding additional strokes. If the financial numbering system is not specified, applications should use the default numbering system as a fallback.
166*912701f9SAndroid Build Coastguard Worker
167*912701f9SAndroid Build Coastguard WorkerThe categories defined for other numbering systems can be used in a Unicode locale identifier to select the proper numbering system without having to know the specific numbering system by name. For example:
168*912701f9SAndroid Build Coastguard Worker
169*912701f9SAndroid Build Coastguard Worker*   To select Hindi language using the native digits for numeric formatting, use locale ID: "hi-IN-u-nu-native".
170*912701f9SAndroid Build Coastguard Worker*   To select Chinese language using the appropriate financial numerals, use locale ID: "zh-u-nu-finance".
171*912701f9SAndroid Build Coastguard Worker*   To select Tamil language using the traditional Tamil numerals, use locale ID: "ta-u-nu-traditio".
172*912701f9SAndroid Build Coastguard Worker*   To select Arabic language using western digits 0-9, use locale ID: "ar-u-nu-latn".
173*912701f9SAndroid Build Coastguard Worker
174*912701f9SAndroid Build Coastguard WorkerFor more information on numbering systems and their definitions, see _[Section 1: Numbering Systems](#Numbering_Systems)_.
175*912701f9SAndroid Build Coastguard Worker
176*912701f9SAndroid Build Coastguard Worker### <a name="Number_Symbols" href="#Number_Symbols">Number Symbols</a>
177*912701f9SAndroid Build Coastguard Worker
178*912701f9SAndroid Build Coastguard Worker```xml
179*912701f9SAndroid Build Coastguard Worker<!ELEMENT symbols (alias | (decimal*, group*, list*, percentSign*, nativeZeroDigit*, patternDigit*, plusSign*, minusSign*, approximatelySign*, exponential*, superscriptingExponent*, perMille*, infinity*, nan*, currencyDecimal*, currencyGroup*, timeSeparator*, special*)) >
180*912701f9SAndroid Build Coastguard Worker```
181*912701f9SAndroid Build Coastguard Worker
182*912701f9SAndroid Build Coastguard WorkerNumber symbols define the localized symbols that are commonly used when formatting numbers in a given locale. These symbols can be referenced using a number formatting pattern as defined in _[Section 3: Number Format Patterns](#Number_Format_Patterns)_.
183*912701f9SAndroid Build Coastguard Worker
184*912701f9SAndroid Build Coastguard WorkerThe available number symbols are as follows:
185*912701f9SAndroid Build Coastguard Worker
186*912701f9SAndroid Build Coastguard Worker**decimal**
187*912701f9SAndroid Build Coastguard Worker
188*912701f9SAndroid Build Coastguard Worker> separates the integer and fractional part of the number.
189*912701f9SAndroid Build Coastguard Worker
190*912701f9SAndroid Build Coastguard Worker**group**
191*912701f9SAndroid Build Coastguard Worker
192*912701f9SAndroid Build Coastguard Worker> separates clusters of integer digits to make large numbers more legible; commonly used for thousands (grouping size 3, e.g. "100,000,000") or in some locales, ten-thousands (grouping size 4, e.g. "1,0000,0000"). There may be two different grouping sizes: The _primary grouping size_ used for the least significant integer group, and the _secondary grouping size_ used for more significant groups; these are not the same in all locales (e.g. "12,34,56,789"). If a pattern contains multiple grouping separators, the interval between the last one and the end of the integer defines the primary grouping size, and the interval between the last two defines the secondary grouping size. All others are ignored, so "#,##,###,####" == "###,###,####" == "##,#,###,####".
193*912701f9SAndroid Build Coastguard Worker
194*912701f9SAndroid Build Coastguard Worker**list**
195*912701f9SAndroid Build Coastguard Worker
196*912701f9SAndroid Build Coastguard Worker> symbol used to separate numbers in a list intended to represent structured data such as an array; must be different from the **decimal** value. This list separator is for “non-linguistic” usage as opposed to the listPatterns for “linguistic” lists (e.g. “Bob, Carol, and Ted”) described in Part 2, _[List Patterns](tr35-general.md#ListPatterns)_.
197*912701f9SAndroid Build Coastguard Worker
198*912701f9SAndroid Build Coastguard Worker**percentSign**
199*912701f9SAndroid Build Coastguard Worker
200*912701f9SAndroid Build Coastguard Worker> symbol used to indicate a percentage (1/100th) amount. (If present, the value is also multiplied by 100 before formatting. That way 1.23 → 123%)
201*912701f9SAndroid Build Coastguard Worker
202*912701f9SAndroid Build Coastguard Worker~~**nativeZeroDigit**~~
203*912701f9SAndroid Build Coastguard Worker
204*912701f9SAndroid Build Coastguard Worker> Deprecated - do not use.
205*912701f9SAndroid Build Coastguard Worker
206*912701f9SAndroid Build Coastguard Worker~~**patternDigit**~~
207*912701f9SAndroid Build Coastguard Worker
208*912701f9SAndroid Build Coastguard Worker> Deprecated. This was formerly used to provide the localized pattern character corresponding to '#', but localization of the pattern characters themselves has been deprecated for some time (determining the locale-specific _replacements_ for pattern characters is of course not deprecated and is part of normal number formatting).
209*912701f9SAndroid Build Coastguard Worker
210*912701f9SAndroid Build Coastguard Worker**minusSign**
211*912701f9SAndroid Build Coastguard Worker
212*912701f9SAndroid Build Coastguard Worker> Symbol used to denote negative value.
213*912701f9SAndroid Build Coastguard Worker
214*912701f9SAndroid Build Coastguard Worker**plusSign**
215*912701f9SAndroid Build Coastguard Worker
216*912701f9SAndroid Build Coastguard Worker> Symbol used to denote positive value.  It can be used to produce modified patterns, so that 3.12 is formatted as "+3.12", for example. The standard number patterns (except for type="accounting") will contain the minusSign, explicitly or implicitly. In the explicit pattern, the value of the plusSign can be substituted for the value of the minusSign to produce a pattern that has an explicit plus sign.
217*912701f9SAndroid Build Coastguard Worker
218*912701f9SAndroid Build Coastguard Worker**approximatelySign**
219*912701f9SAndroid Build Coastguard Worker
220*912701f9SAndroid Build Coastguard Worker> Symbol used to denote a value that is approximate but not exact. The symbol is substituted in place of the minusSign using the same semantics as plusSign substitution.
221*912701f9SAndroid Build Coastguard Worker
222*912701f9SAndroid Build Coastguard Worker**exponential**
223*912701f9SAndroid Build Coastguard Worker
224*912701f9SAndroid Build Coastguard Worker> Symbol separating the mantissa and exponent values.
225*912701f9SAndroid Build Coastguard Worker
226*912701f9SAndroid Build Coastguard Worker**superscriptingExponent**
227*912701f9SAndroid Build Coastguard Worker
228*912701f9SAndroid Build Coastguard Worker> (Programmers are used to the fallback exponent style “1.23E4”, but that should not be shown to end-users. Instead, the exponential notation superscriptingExponent should be used to show a format like “1.23 × 10<sup>4</sup>”. ) The superscripting can use markup, such as `<sup>4</sup>` in HTML, or for the special case of Latin digits, use the superscript characters: U+207B ( ⁻ ), U+2070 ( ⁰ ), U+00B9 ( ¹ ), U+00B2 ( ² ), U+00B3 ( ³ ), U+2074 ( ⁴ ) .. U+2079 ( ⁹ ).
229*912701f9SAndroid Build Coastguard Worker
230*912701f9SAndroid Build Coastguard Worker**perMille**
231*912701f9SAndroid Build Coastguard Worker
232*912701f9SAndroid Build Coastguard Worker> symbol used to indicate a per-mille (1/1000th) amount. (If present, the value is also multiplied by 1000 before formatting. That way 1.23 → 1230 [1/000])
233*912701f9SAndroid Build Coastguard Worker
234*912701f9SAndroid Build Coastguard Worker**infinity**
235*912701f9SAndroid Build Coastguard Worker
236*912701f9SAndroid Build Coastguard Worker> The infinity sign. Corresponds to the IEEE infinity bit pattern.
237*912701f9SAndroid Build Coastguard Worker
238*912701f9SAndroid Build Coastguard Worker**nan - Not a number**
239*912701f9SAndroid Build Coastguard Worker
240*912701f9SAndroid Build Coastguard Worker> The NaN sign. Corresponds to the IEEE NaN bit pattern.
241*912701f9SAndroid Build Coastguard Worker
242*912701f9SAndroid Build Coastguard Worker**currencyDecimal**
243*912701f9SAndroid Build Coastguard Worker
244*912701f9SAndroid Build Coastguard Worker> Optional. If specified, then for currency formatting/parsing this is used as the decimal separator instead of using the regular decimal separator; otherwise, the regular decimal separator is used.
245*912701f9SAndroid Build Coastguard Worker
246*912701f9SAndroid Build Coastguard Worker**currencyGroup**
247*912701f9SAndroid Build Coastguard Worker
248*912701f9SAndroid Build Coastguard Worker> Optional. If specified, then for currency formatting/parsing this is used as the group separator instead of using the regular group separator; otherwise, the regular group separator is used.
249*912701f9SAndroid Build Coastguard Worker
250*912701f9SAndroid Build Coastguard Worker**timeSeparator**
251*912701f9SAndroid Build Coastguard Worker
252*912701f9SAndroid Build Coastguard Worker> This replaces any use of the timeSeparator pattern character in a date-time format pattern (no timeSeparator pattern character is currently defined, see note below). This allows the same time format to be used for multiple number systems when the time separator depends on the number system. For example, the time format for Arabic should be COLON when using the Latin numbering system (0, 1, 2, …), but when the Arabic numbering system is used (٠‎ - ١‎ - ٢‎ …), the traditional time separator in older print styles was often ARABIC COMMA.
253*912701f9SAndroid Build Coastguard Worker>
254*912701f9SAndroid Build Coastguard Worker> **Note:** In CLDR 26 the timeSeparator pattern character was specified to be COLON. This was withdrawn in CLDR 28 due to backward compatibility issues, and no timeSeparator pattern character is currently defined. No CLDR locales are known to have a need to specify timeSeparator symbols that depend on number system; if this changes in the future a different timeSeparator pattern character will be defined. In the meantime, since CLDR data consumers can still request the timeSeparator symbol, it should match the symbol actually used in the [timeFormats](tr35-dates.md#timeFormats) and [availableFormats](tr35-dates.md#availableFormats_appendItems) items.
255*912701f9SAndroid Build Coastguard Worker
256*912701f9SAndroid Build Coastguard WorkerExample:
257*912701f9SAndroid Build Coastguard Worker
258*912701f9SAndroid Build Coastguard Worker```xml
259*912701f9SAndroid Build Coastguard Worker<symbols>
260*912701f9SAndroid Build Coastguard Worker    <decimal>.</decimal>
261*912701f9SAndroid Build Coastguard Worker    <group>,</group>
262*912701f9SAndroid Build Coastguard Worker    <list>;</list>
263*912701f9SAndroid Build Coastguard Worker    <percentSign>%</percentSign>
264*912701f9SAndroid Build Coastguard Worker    <patternDigit>#</patternDigit>
265*912701f9SAndroid Build Coastguard Worker    <plusSign>+</plusSign>
266*912701f9SAndroid Build Coastguard Worker    <minusSign>-</minusSign>
267*912701f9SAndroid Build Coastguard Worker    <approximatelySign>~</approximatelySign>
268*912701f9SAndroid Build Coastguard Worker    <exponential>E</exponential>
269*912701f9SAndroid Build Coastguard Worker    <superscriptingExponent>×</superscriptingExponent>
270*912701f9SAndroid Build Coastguard Worker    <perMille>‰</perMille>
271*912701f9SAndroid Build Coastguard Worker    <infinity>∞</infinity>
272*912701f9SAndroid Build Coastguard Worker    <nan>☹</nan>
273*912701f9SAndroid Build Coastguard Worker    <timeSeparator>:</timeSeparator>
274*912701f9SAndroid Build Coastguard Worker</symbols>
275*912701f9SAndroid Build Coastguard Worker```
276*912701f9SAndroid Build Coastguard Worker
277*912701f9SAndroid Build Coastguard Worker```xml
278*912701f9SAndroid Build Coastguard Worker<!ATTLIST symbols numberSystem CDATA #IMPLIED >
279*912701f9SAndroid Build Coastguard Worker```
280*912701f9SAndroid Build Coastguard WorkerThe `numberSystem` attribute is used to specify that the given number symbols are to be used when the given numbering system is active. Number symbols can only be defined for numbering systems of the "numeric" type, since any special symbols required for an algorithmic numbering system should be specified by the RBNF formatting rules used for that numbering system. By default, number symbols without a specific `numberSystem` attribute are assumed to be used for the "latn" numbering system, which is western (ASCII) digits. Locales that specify a numbering system other than "latn" as the default should also specify number formatting symbols that are appropriate for use within the context of the given numbering system. For example, a locale that uses the Arabic-Indic digits as its default would likely use an Arabic comma for the grouping separator rather than the ASCII comma.
281*912701f9SAndroid Build Coastguard WorkerFor more information on numbering systems and their definitions, see _[Section 1: Numbering Systems](#Numbering_Systems)_.
282*912701f9SAndroid Build Coastguard Worker
283*912701f9SAndroid Build Coastguard Worker### <a name="Number_Formats" href="#Number_Formats">Number Formats</a>
284*912701f9SAndroid Build Coastguard Worker
285*912701f9SAndroid Build Coastguard Worker```xml
286*912701f9SAndroid Build Coastguard Worker<!ELEMENT decimalFormats (alias | (default*, decimalFormatLength*, special*)) >
287*912701f9SAndroid Build Coastguard Worker<!ELEMENT decimalFormatLength (alias | (default*, decimalFormat*, special*)) >
288*912701f9SAndroid Build Coastguard Worker<!ATTLIST decimalFormatLength type ( full | long | medium | short ) #IMPLIED >
289*912701f9SAndroid Build Coastguard Worker<!ELEMENT decimalFormat (alias | (pattern*, special*)) >
290*912701f9SAndroid Build Coastguard Worker```
291*912701f9SAndroid Build Coastguard Worker
292*912701f9SAndroid Build Coastguard Worker(scientificFormats, percentFormats have the same structure)
293*912701f9SAndroid Build Coastguard Worker
294*912701f9SAndroid Build Coastguard WorkerNumber formats are used to define the rules for formatting numeric quantities using the pattern syntax described in _[Section 3: Number Format Patterns](#Number_Format_Patterns)_.
295*912701f9SAndroid Build Coastguard Worker
296*912701f9SAndroid Build Coastguard WorkerDifferent formats are provided for different contexts, as follows:
297*912701f9SAndroid Build Coastguard Worker
298*912701f9SAndroid Build Coastguard Worker**decimalFormats**
299*912701f9SAndroid Build Coastguard Worker
300*912701f9SAndroid Build Coastguard Worker> The normal locale specific way to write a base 10 number. Variations of the decimalFormat pattern are provided that allow compact number formatting.
301*912701f9SAndroid Build Coastguard Worker
302*912701f9SAndroid Build Coastguard Worker**percentFormats**
303*912701f9SAndroid Build Coastguard Worker
304*912701f9SAndroid Build Coastguard Worker> Pattern for use with percentage formatting
305*912701f9SAndroid Build Coastguard Worker
306*912701f9SAndroid Build Coastguard Worker**scientificFormats**
307*912701f9SAndroid Build Coastguard Worker
308*912701f9SAndroid Build Coastguard Worker> Pattern for use with scientific (exponent) formatting.
309*912701f9SAndroid Build Coastguard Worker
310*912701f9SAndroid Build Coastguard WorkerExample:
311*912701f9SAndroid Build Coastguard Worker
312*912701f9SAndroid Build Coastguard Worker```xml
313*912701f9SAndroid Build Coastguard Worker<decimalFormats>
314*912701f9SAndroid Build Coastguard Worker  <decimalFormatLength type="long">
315*912701f9SAndroid Build Coastguard Worker    <decimalFormat>
316*912701f9SAndroid Build Coastguard Worker      <pattern>#,##0.###</pattern>
317*912701f9SAndroid Build Coastguard Worker    </decimalFormat>
318*912701f9SAndroid Build Coastguard Worker  </decimalFormatLength>
319*912701f9SAndroid Build Coastguard Worker</decimalFormats>
320*912701f9SAndroid Build Coastguard Worker
321*912701f9SAndroid Build Coastguard Worker<scientificFormats>
322*912701f9SAndroid Build Coastguard Worker  <default type="long"/>
323*912701f9SAndroid Build Coastguard Worker  <scientificFormatLength type="long">
324*912701f9SAndroid Build Coastguard Worker    <scientificFormat>
325*912701f9SAndroid Build Coastguard Worker      <pattern>0.000###E+00</pattern>
326*912701f9SAndroid Build Coastguard Worker    </scientificFormat>
327*912701f9SAndroid Build Coastguard Worker  </scientificFormatLength>
328*912701f9SAndroid Build Coastguard Worker  <scientificFormatLength type="medium">
329*912701f9SAndroid Build Coastguard Worker    <scientificFormat>
330*912701f9SAndroid Build Coastguard Worker      <pattern>0.00##E+00</pattern>
331*912701f9SAndroid Build Coastguard Worker    </scientificFormat>
332*912701f9SAndroid Build Coastguard Worker  </scientificFormatLength>
333*912701f9SAndroid Build Coastguard Worker</scientificFormats>
334*912701f9SAndroid Build Coastguard Worker
335*912701f9SAndroid Build Coastguard Worker<percentFormats>
336*912701f9SAndroid Build Coastguard Worker  <percentFormatLength type="long">
337*912701f9SAndroid Build Coastguard Worker    <percentFormat>
338*912701f9SAndroid Build Coastguard Worker      <pattern>#,##0%</pattern>
339*912701f9SAndroid Build Coastguard Worker    </percentFormat>
340*912701f9SAndroid Build Coastguard Worker  </percentFormatLength>
341*912701f9SAndroid Build Coastguard Worker</percentFormats>
342*912701f9SAndroid Build Coastguard Worker```
343*912701f9SAndroid Build Coastguard Worker
344*912701f9SAndroid Build Coastguard Worker```xml
345*912701f9SAndroid Build Coastguard Worker<!ATTLIST symbols numberSystem CDATA #IMPLIED >
346*912701f9SAndroid Build Coastguard Worker```
347*912701f9SAndroid Build Coastguard Worker
348*912701f9SAndroid Build Coastguard WorkerThe `numberSystem` attribute is used to specify that the given number formatting pattern(s) are to be used when the given numbering system is active. By default, number formatting patterns without a specific `numberSystem` attribute are assumed to be used for the "latn" numbering system, which is western (ASCII) digits. Locales that specify a numbering system other than "latn" as the default should also specify number formatting patterns that are appropriate for use within the context of the given numbering system.
349*912701f9SAndroid Build Coastguard WorkerFor more information on numbering systems and their definitions, see _[Section 1: Numbering Systems](#Numbering_Systems)_.
350*912701f9SAndroid Build Coastguard Worker
351*912701f9SAndroid Build Coastguard Worker#### <a name="Compact_Number_Formats" href="#Compact_Number_Formats">Compact Number Formats</a>
352*912701f9SAndroid Build Coastguard Worker
353*912701f9SAndroid Build Coastguard WorkerA pattern `type` attribute is used for _compact number formats_, such as the following:
354*912701f9SAndroid Build Coastguard Worker
355*912701f9SAndroid Build Coastguard Worker```xml
356*912701f9SAndroid Build Coastguard Worker<decimalFormatLength type="long">
357*912701f9SAndroid Build Coastguard Worker    <decimalFormat>
358*912701f9SAndroid Build Coastguard Worker        <pattern type="1000" count="one">0 millier</pattern>
359*912701f9SAndroid Build Coastguard Worker        <pattern type="1000" count="other">0 milliers</pattern>
360*912701f9SAndroid Build Coastguard Worker        <pattern type="10000" count="one">00 mille</pattern>
361*912701f9SAndroid Build Coastguard Worker        <pattern type="10000" count="other">00 mille</pattern>
362*912701f9SAndroid Build Coastguard Worker        <pattern type="100000" count="one">000 mille</pattern>
363*912701f9SAndroid Build Coastguard Worker        <pattern type="100000" count="other">000 mille</pattern>
364*912701f9SAndroid Build Coastguard Worker        <pattern type="1000000" count="one">0 million</pattern>
365*912701f9SAndroid Build Coastguard Worker        <pattern type="1000000" count="other">0 millions</pattern>
366*912701f9SAndroid Build Coastguard Worker367*912701f9SAndroid Build Coastguard Worker    </decimalFormat>
368*912701f9SAndroid Build Coastguard Worker</decimalFormatLength>
369*912701f9SAndroid Build Coastguard Worker<decimalFormatLength type="short">
370*912701f9SAndroid Build Coastguard Worker    <decimalFormat>
371*912701f9SAndroid Build Coastguard Worker        <pattern type="1000" count="one">0 K</pattern>
372*912701f9SAndroid Build Coastguard Worker        <pattern type="1000" count="other">0 K</pattern>
373*912701f9SAndroid Build Coastguard Worker        <pattern type="10000" count="one">00 K</pattern>
374*912701f9SAndroid Build Coastguard Worker        <pattern type="10000" count="other">00 K</pattern>
375*912701f9SAndroid Build Coastguard Worker        <pattern type="100000" count="one">000 K</pattern>
376*912701f9SAndroid Build Coastguard Worker        <pattern type="100000" count="other">000 K</pattern>
377*912701f9SAndroid Build Coastguard Worker        <pattern type="1000000" count="one">0 M</pattern>
378*912701f9SAndroid Build Coastguard Worker        <pattern type="1000000" count="other">0 M</pattern>
379*912701f9SAndroid Build Coastguard Worker380*912701f9SAndroid Build Coastguard Worker    </decimalFormat>
381*912701f9SAndroid Build Coastguard Worker382*912701f9SAndroid Build Coastguard Worker<currencyFormatLength type="short">
383*912701f9SAndroid Build Coastguard Worker    <currencyFormat type="standard">
384*912701f9SAndroid Build Coastguard Worker        <pattern type="1000" count="one">0 K ¤</pattern>
385*912701f9SAndroid Build Coastguard Worker        <pattern type="1000" count="other">0 K ¤</pattern>
386*912701f9SAndroid Build Coastguard Worker        <pattern type="10000" count="one">00 K ¤</pattern>
387*912701f9SAndroid Build Coastguard Worker        <pattern type="10000" count="other">00 K ¤</pattern>
388*912701f9SAndroid Build Coastguard Worker        <pattern type="100000" count="one">000 K ¤</pattern>
389*912701f9SAndroid Build Coastguard Worker        <pattern type="100000" count="other">000 K ¤</pattern>
390*912701f9SAndroid Build Coastguard Worker        <pattern type="1000000" count="one">0 M ¤</pattern>
391*912701f9SAndroid Build Coastguard Worker        <pattern type="1000000" count="other">0 M ¤</pattern>
392*912701f9SAndroid Build Coastguard Worker```
393*912701f9SAndroid Build Coastguard Worker
394*912701f9SAndroid Build Coastguard WorkerFormats can be supplied for numbers (as above) or for currencies or other units. They can also be used with ranges of numbers, resulting in formatting strings like “$10K” or “$3–7M”.
395*912701f9SAndroid Build Coastguard Worker
396*912701f9SAndroid Build Coastguard WorkerTo format a number N, the greatest type less than or equal to N is used, with the appropriate plural category. N is divided by the type, after removing the number of zeros in the pattern, less 1. APIs supporting this format should provide control over the number of significant or fraction digits.
397*912701f9SAndroid Build Coastguard Worker
398*912701f9SAndroid Build Coastguard WorkerThe default pattern for any type that is not supplied is the special value “0”, as in the following. The value “0” must be used when a child locale overrides a parent locale to drop the compact pattern for that type and use the default pattern.
399*912701f9SAndroid Build Coastguard Worker
400*912701f9SAndroid Build Coastguard Worker `<pattern type="1" count="one">0</pattern>`
401*912701f9SAndroid Build Coastguard Worker
402*912701f9SAndroid Build Coastguard WorkerIf the value is precisely “0”, either explicit or defaulted, then the normal number format pattern for that sort of object is supplied — either `<decimalFormat>` or `<currencyFormat type="standard">` — with the normal formatting for the locale (such as the grouping separators). However, for the “0” case by default the significant digits are adjusted for consistency, typically to 2 or 3 digits, and the maximum fractional digits are set to 0 (for both currencies and plain decimal). Thus the output would be $12, not $12.01. APIs may, however, allow these default behaviors to be overridden.
403*912701f9SAndroid Build Coastguard Worker
404*912701f9SAndroid Build Coastguard WorkerWith the data above, N=12345 matches `<pattern type="10000" count="other">00 K</pattern>`. N is divided by 1000 (obtained from 10000 after removing "00" and restoring one "0"). The result is formatted according to the normal decimal pattern. With no fractional digits, that yields "12 K".
405*912701f9SAndroid Build Coastguard Worker
406*912701f9SAndroid Build Coastguard WorkerFormatting 1200 in USD would result in “1.2 K $”, while 990 implicitly maps to the special value “0”, which maps to `<currencyFormat type="standard"><pattern>#,##0.00 ¤</pattern>`, and would result in simply “990 $”.
407*912701f9SAndroid Build Coastguard Worker
408*912701f9SAndroid Build Coastguard WorkerThe short format is designed for UI environments where space is at a premium, and should ideally result in a formatted string no more than about 6 em wide (with no fractional digits).
409*912701f9SAndroid Build Coastguard Worker
410*912701f9SAndroid Build Coastguard Worker#### <a name="Currency_Formats" href="#Currency_Formats">Currency Formats</a>
411*912701f9SAndroid Build Coastguard Worker
412*912701f9SAndroid Build Coastguard WorkerPatterns for use with currency formatting:
413*912701f9SAndroid Build Coastguard Worker
414*912701f9SAndroid Build Coastguard Worker```xml
415*912701f9SAndroid Build Coastguard Worker<!ELEMENT currencyFormats (alias | (default*, currencySpacing*, currencyFormatLength*, currencyPatternAppendISO*, unitPattern*, special*)) >
416*912701f9SAndroid Build Coastguard Worker<!ELEMENT currencyFormatLength (alias | (default*, currencyFormat*, special*)) >
417*912701f9SAndroid Build Coastguard Worker<!ATTLIST currencyFormatLength type ( full | long | medium | short ) #IMPLIED >
418*912701f9SAndroid Build Coastguard Worker<!ELEMENT currencyFormat (alias | (pattern*, special*)) >
419*912701f9SAndroid Build Coastguard Worker<!ATTLIST currencyFormat type NMTOKEN "standard" >
420*912701f9SAndroid Build Coastguard Worker    <!--@MATCH:literal/accounting, standard-->
421*912701f9SAndroid Build Coastguard Worker<!ELEMENT currencyPatternAppendISO ( #PCDATA ) >
422*912701f9SAndroid Build Coastguard Worker```
423*912701f9SAndroid Build Coastguard Worker
424*912701f9SAndroid Build Coastguard WorkerThe following additional elements were intended to allow proper placement of the currency symbol relative to the numeric quantity. These are specified in the root locale and typically not overridden in any other locale. However, as of CLDR 42, the preferred approach to controlling placement of the currency symbol is use of the `alt="alphaNextToNumber"` variant for `currencyFormat` `pattern`s. See below and _[- Currencies](#Currencies)_ for additional information on the use of these options.
425*912701f9SAndroid Build Coastguard Worker
426*912701f9SAndroid Build Coastguard Worker```xml
427*912701f9SAndroid Build Coastguard Worker<!ELEMENT currencySpacing (alias | (beforeCurrency*, afterCurrency*, special*)) >
428*912701f9SAndroid Build Coastguard Worker<!ELEMENT beforeCurrency (alias | (currencyMatch*, surroundingMatch*, insertBetween*)) >
429*912701f9SAndroid Build Coastguard Worker<!ELEMENT afterCurrency (alias | (currencyMatch*, surroundingMatch*, insertBetween*)) >
430*912701f9SAndroid Build Coastguard Worker<!ELEMENT currencyMatch ( #PCDATA ) >
431*912701f9SAndroid Build Coastguard Worker<!ELEMENT surroundingMatch ( #PCDATA )) >
432*912701f9SAndroid Build Coastguard Worker<!ELEMENT insertBetween ( #PCDATA ) >
433*912701f9SAndroid Build Coastguard Worker```
434*912701f9SAndroid Build Coastguard Worker
435*912701f9SAndroid Build Coastguard WorkerIn addition to a standard currency format, in which negative currency amounts might typically be displayed as something like “-$3.27”, locales may provide an "accounting" form, in which for "en_US" the same example would appear as “($3.27)”. The locale keyword "cf" can be used to select the standard or accounting form, see [Unicode Currency Format Identifier](tr35.md#UnicodeCurrencyFormatIdentifier).
436*912701f9SAndroid Build Coastguard Worker
437*912701f9SAndroid Build Coastguard Worker```xml
438*912701f9SAndroid Build Coastguard Worker<currencyFormats>
439*912701f9SAndroid Build Coastguard Worker    <currencyFormatLength>
440*912701f9SAndroid Build Coastguard Worker        <currencyFormat type="standard">
441*912701f9SAndroid Build Coastguard Worker            <pattern>¤#,##0.00</pattern>
442*912701f9SAndroid Build Coastguard Worker            <pattern alt="alphaNextToNumber">¤ #,##0.00</pattern>
443*912701f9SAndroid Build Coastguard Worker            <pattern alt="noCurrency">#,##0.00</pattern>
444*912701f9SAndroid Build Coastguard Worker        </currencyFormat>
445*912701f9SAndroid Build Coastguard Worker        <currencyFormat type="accounting">
446*912701f9SAndroid Build Coastguard Worker            <pattern>¤#,##0.00;(¤#,##0.00)</pattern>
447*912701f9SAndroid Build Coastguard Worker            <pattern alt="alphaNextToNumber">¤ #,##0.00;(¤ #,##0.00)</pattern>
448*912701f9SAndroid Build Coastguard Worker            <pattern alt="noCurrency">#,##0.00;(#,##0.00)</pattern>
449*912701f9SAndroid Build Coastguard Worker        </currencyFormat>
450*912701f9SAndroid Build Coastguard Worker    </currencyFormatLength>
451*912701f9SAndroid Build Coastguard Worker    <currencyFormatLength type="short">
452*912701f9SAndroid Build Coastguard Worker        <currencyFormat type="standard">
453*912701f9SAndroid Build Coastguard Worker            <pattern type="1000" count="one">¤0K</pattern>
454*912701f9SAndroid Build Coastguard Worker            <pattern type="1000" count="one" alt="alphaNextToNumber">¤ 0K</pattern>
455*912701f9SAndroid Build Coastguard Worker            <pattern type="1000" count="other">¤0K</pattern>
456*912701f9SAndroid Build Coastguard Worker            <pattern type="1000" count="other" alt="alphaNextToNumber">¤ 0K</pattern>
457*912701f9SAndroid Build Coastguard Worker            ...
458*912701f9SAndroid Build Coastguard Worker            <pattern type="100000000000000" count="other">¤000T</pattern>
459*912701f9SAndroid Build Coastguard Worker            <pattern type="100000000000000" count="other" alt="alphaNextToNumber">¤ 000T</pattern>
460*912701f9SAndroid Build Coastguard Worker        </currencyFormat>
461*912701f9SAndroid Build Coastguard Worker    </currencyFormatLength>
462*912701f9SAndroid Build Coastguard Worker</currencyFormats>
463*912701f9SAndroid Build Coastguard Worker```
464*912701f9SAndroid Build Coastguard Worker
465*912701f9SAndroid Build Coastguard WorkerThe `alt="alphaNextToNumber"` pattern, if available, should be used instead of the standard pattern when the currency symbol character closest to the numeric value has Unicode General Category L (letter). The `alt="alphaNextToNumber"` pattern is typically provided when the standard currency pattern does not have a space between currency symbol and numeric value; the alphaNextToNumber variant adds a non-breaking space if appropriate for the locale.
466*912701f9SAndroid Build Coastguard Worker
467*912701f9SAndroid Build Coastguard WorkerThe `alt="noCurrency"` pattern can be used when a currency-style format is desired but without the currency symbol. This sort of display may be used when formatting a large column of values all in the same currency, for example. For compact currency formats (`<currencyFormatLength type="short">`), the compact decimal format (`<decimalFormatLength type="short">`) should be used if no `alt="noCurrency"` pattern is present (so the `alt="noCurrency"` pattern is typically not needed for compact currency formats).
468*912701f9SAndroid Build Coastguard Worker
469*912701f9SAndroid Build Coastguard Worker```xml
470*912701f9SAndroid Build Coastguard Worker<currencyPatternAppendISO>{0} ¤¤</currencyPatternAppendISO>
471*912701f9SAndroid Build Coastguard Worker```
472*912701f9SAndroid Build Coastguard Worker
473*912701f9SAndroid Build Coastguard WorkerThe `currencyPatternAppendISO` element provides a pattern that can be used to combine currency format that uses a currency symbol (¤ or ¤¤¤¤¤) with the ISO 4217 3-letter code for the same currency (¤¤), to produce a result such as “$1,432.00 USD”. Using such a format is only recommended to resolve ambiguity when:
474*912701f9SAndroid Build Coastguard Worker* The currency symbol being used is the narrow symbol (¤¤¤¤¤) or has the same value as the narrow symbol, and
475*912701f9SAndroid Build Coastguard Worker* The currency symbol does not have the same value as the ISO 4217 3-letter code.
476*912701f9SAndroid Build Coastguard WorkerMost locales will not need to override the pattern provided in root, shown in the xml sample above.
477*912701f9SAndroid Build Coastguard Worker
478*912701f9SAndroid Build Coastguard Worker### <a name="Miscellaneous_Patterns" href="#Miscellaneous_Patterns">Miscellaneous Patterns</a>
479*912701f9SAndroid Build Coastguard Worker
480*912701f9SAndroid Build Coastguard Worker```xml
481*912701f9SAndroid Build Coastguard Worker<!ELEMENT miscPatterns (alias | (default*, pattern*, special*)) >
482*912701f9SAndroid Build Coastguard Worker<!ATTLIST miscPatterns numberSystem CDATA #IMPLIED >
483*912701f9SAndroid Build Coastguard Worker```
484*912701f9SAndroid Build Coastguard Worker
485*912701f9SAndroid Build Coastguard WorkerThe miscPatterns supply additional patterns for special purposes. The currently defined values are:
486*912701f9SAndroid Build Coastguard Worker
487*912701f9SAndroid Build Coastguard Worker**approximately**
488*912701f9SAndroid Build Coastguard Worker
489*912701f9SAndroid Build Coastguard Worker> indicates an approximate number, such as: “\~99”. This pattern is not currently in use; see ICU-20163.
490*912701f9SAndroid Build Coastguard Worker
491*912701f9SAndroid Build Coastguard Worker**atMost**
492*912701f9SAndroid Build Coastguard Worker
493*912701f9SAndroid Build Coastguard Worker> indicates a number or lower, such as: “`≤`99” to indicate that there are 99 items or fewer.
494*912701f9SAndroid Build Coastguard Worker
495*912701f9SAndroid Build Coastguard Worker**atLeast**
496*912701f9SAndroid Build Coastguard Worker
497*912701f9SAndroid Build Coastguard Worker> indicates a number or higher, such as: “99+” to indicate that there are 99 items or more.
498*912701f9SAndroid Build Coastguard Worker
499*912701f9SAndroid Build Coastguard Worker**range**
500*912701f9SAndroid Build Coastguard Worker
501*912701f9SAndroid Build Coastguard Worker> indicates a range of numbers, such as: “99–103” to indicate that there are from 99 to 103 items.
502*912701f9SAndroid Build Coastguard Worker
503*912701f9SAndroid Build Coastguard Worker_For example:_
504*912701f9SAndroid Build Coastguard Worker
505*912701f9SAndroid Build Coastguard Worker```xml
506*912701f9SAndroid Build Coastguard Worker<miscPatterns numberSystem="…">
507*912701f9SAndroid Build Coastguard Worker  <pattern type="approximately">~{0}</pattern>
508*912701f9SAndroid Build Coastguard Worker  <pattern type="atLeast">≥{0}</pattern>
509*912701f9SAndroid Build Coastguard Worker  <pattern type="atMost">≤{0}</pattern>
510*912701f9SAndroid Build Coastguard Worker  <pattern type="range">{0}–{1}</pattern>
511*912701f9SAndroid Build Coastguard Worker</miscPatterns>
512*912701f9SAndroid Build Coastguard Worker```
513*912701f9SAndroid Build Coastguard Worker
514*912701f9SAndroid Build Coastguard Worker### <a name="Minimal_Pairs" href="#Minimal_Pairs">Minimal Pairs</a>
515*912701f9SAndroid Build Coastguard Worker
516*912701f9SAndroid Build Coastguard Worker```xml
517*912701f9SAndroid Build Coastguard Worker<!ELEMENT minimalPairs ( alias | ( pluralMinimalPairs*, ordinalMinimalPairs*, caseMinimalPairs*, genderMinimalPairs*, special* ) ) >
518*912701f9SAndroid Build Coastguard Worker```
519*912701f9SAndroid Build Coastguard Worker```xml
520*912701f9SAndroid Build Coastguard Worker<!ELEMENT pluralMinimalPairs ( #PCDATA ) >
521*912701f9SAndroid Build Coastguard Worker<!ATTLIST pluralMinimalPairs count NMTOKEN #IMPLIED >
522*912701f9SAndroid Build Coastguard Worker```
523*912701f9SAndroid Build Coastguard Worker```xml
524*912701f9SAndroid Build Coastguard Worker<!ELEMENT ordinalMinimalPairs ( #PCDATA ) >
525*912701f9SAndroid Build Coastguard Worker<!ATTLIST ordinalMinimalPairs ordinal NMTOKEN #IMPLIED >
526*912701f9SAndroid Build Coastguard Worker```
527*912701f9SAndroid Build Coastguard Worker
528*912701f9SAndroid Build Coastguard Worker```xml
529*912701f9SAndroid Build Coastguard Worker<!ELEMENT caseMinimalPairs ( #PCDATA ) >
530*912701f9SAndroid Build Coastguard Worker<!ATTLIST caseMinimalPairs case NMTOKEN #REQUIRED >
531*912701f9SAndroid Build Coastguard Worker```
532*912701f9SAndroid Build Coastguard Worker
533*912701f9SAndroid Build Coastguard Worker```xml
534*912701f9SAndroid Build Coastguard Worker<!ELEMENT genderMinimalPairs ( #PCDATA ) >
535*912701f9SAndroid Build Coastguard Worker<!ATTLIST genderMinimalPairs gender NMTOKEN #REQUIRED >
536*912701f9SAndroid Build Coastguard Worker```
537*912701f9SAndroid Build Coastguard Worker
538*912701f9SAndroid Build Coastguard WorkerMinimal pairs provide examples that justify why multiple plural or ordinal categories exist, and for providing contextual examples for verifying consistency of translations. The allowable values for the `count`, `ordinal`, `case`, and `gender` attributes are found in the dtd file.
539*912701f9SAndroid Build Coastguard Worker
540*912701f9SAndroid Build Coastguard WorkerExamples
541*912701f9SAndroid Build Coastguard Worker
542*912701f9SAndroid Build Coastguard Worker```xml
543*912701f9SAndroid Build Coastguard Worker<minimalPairs>
544*912701f9SAndroid Build Coastguard Worker    <pluralMinimalPairs count="one">{0} Tag</pluralMinimalPairs>
545*912701f9SAndroid Build Coastguard Worker    <pluralMinimalPairs count="other">{0} Tage</pluralMinimalPairs>
546*912701f9SAndroid Build Coastguard Worker
547*912701f9SAndroid Build Coastguard Worker    <ordinalMinimalPairs ordinal="other">{0}. Abzweigung nach rechts nehmen</ordinalMinimalPairs>
548*912701f9SAndroid Build Coastguard Worker
549*912701f9SAndroid Build Coastguard Worker    <caseMinimalPairs case="accusative">… für {0} …</caseMinimalPairs>
550*912701f9SAndroid Build Coastguard Worker    <caseMinimalPairs case="dative">… mit {0} …</caseMinimalPairs>
551*912701f9SAndroid Build Coastguard Worker    <caseMinimalPairs case="genitive">Anstatt {0} …</caseMinimalPairs>
552*912701f9SAndroid Build Coastguard Worker    <caseMinimalPairs case="nominative">{0} kostet (kosten) € 3,50.</caseMinimalPairs>
553*912701f9SAndroid Build Coastguard Worker
554*912701f9SAndroid Build Coastguard Worker    <genderMinimalPairs gender="feminine">Die {0} ist …</genderMinimalPairs>
555*912701f9SAndroid Build Coastguard Worker    <genderMinimalPairs gender="masculine">Der {0} ist …</genderMinimalPairs>
556*912701f9SAndroid Build Coastguard Worker    <genderMinimalPairs gender="neuter">Das {0} ist …</genderMinimalPairs>
557*912701f9SAndroid Build Coastguard Worker</minimalPairs>
558*912701f9SAndroid Build Coastguard Worker```
559*912701f9SAndroid Build Coastguard Worker
560*912701f9SAndroid Build Coastguard Worker
561*912701f9SAndroid Build Coastguard WorkerFor more information, see [Plural Rules](https://cldr.unicode.org/index/cldr-spec/plural-rules) and [Grammatical Inflection](https://cldr.unicode.org/translation/grammatical-inflection).
562*912701f9SAndroid Build Coastguard Worker
563*912701f9SAndroid Build Coastguard Worker## <a name="Number_Format_Patterns" href="#Number_Format_Patterns">Number Format Patterns</a>
564*912701f9SAndroid Build Coastguard Worker
565*912701f9SAndroid Build Coastguard Worker### <a name="Number_Patterns" href="#Number_Patterns">Number Patterns</a>
566*912701f9SAndroid Build Coastguard Worker
567*912701f9SAndroid Build Coastguard WorkerNumber patterns affect how numbers are interpreted in a localized context. Here are some examples, based on the French locale. The "." shows where the decimal point should go. The "," shows where the thousands separator should go. A "0" indicates zero-padding: if the number is too short, a zero (in the locale's numeric set) will go there. A "#" indicates no padding: if the number is too short, nothing goes there. A "¤" shows where the currency sign will go. The following illustrates the effects of different patterns for the French locale, with the number "1234.567". Notice how the pattern characters ',' and '.' are replaced by the characters appropriate for the locale.
568*912701f9SAndroid Build Coastguard Worker
569*912701f9SAndroid Build Coastguard Worker###### Table: <a name="Number_Pattern_Examples" href="#Number_Pattern_Examples">Number Pattern Examples</a>
570*912701f9SAndroid Build Coastguard Worker
571*912701f9SAndroid Build Coastguard Worker| Pattern | Currency | Text |
572*912701f9SAndroid Build Coastguard Worker| --- | --- | --- |
573*912701f9SAndroid Build Coastguard Worker| #,##0.## | _n/a_ | 1 234,57 |
574*912701f9SAndroid Build Coastguard Worker| #,##0.### | _n/a_ | 1 234,567 |
575*912701f9SAndroid Build Coastguard Worker| ###0.##### | _n/a_ | 1234,567 |
576*912701f9SAndroid Build Coastguard Worker| ###0.0000# | _n/a_ | 1234,5670 |
577*912701f9SAndroid Build Coastguard Worker| 00000.0000 | _n/a_ | 01234,5670 |
578*912701f9SAndroid Build Coastguard Worker| #,##0.00 ¤ | EUR | 1 234,57 € |
579*912701f9SAndroid Build Coastguard Worker|| JPY | 1 235 ¥JP |
580*912701f9SAndroid Build Coastguard Worker
581*912701f9SAndroid Build Coastguard WorkerThe number of # placeholder characters before the decimal does not matter, since no limit is placed on the maximum number of digits. There should, however, be at least one zero someplace in the pattern. In currency formats, the number of digits after the decimal also does not matter, since the information in the supplemental data (see _[Supplemental Currency Data](#Supplemental_Currency_Data))_ is used to override the number of decimal places — and the rounding — according to the currency that is being formatted. That can be seen in the above chart, with the difference between Yen and Euro formatting.
582*912701f9SAndroid Build Coastguard Worker
583*912701f9SAndroid Build Coastguard WorkerTo ensure correct layout, especially in currency patterns in which a variety of symbols may be used, number patterns may contain (invisible) bidirectional text format characters such as LRM, RLM, and ALM.
584*912701f9SAndroid Build Coastguard Worker
585*912701f9SAndroid Build Coastguard Worker_When parsing using a pattern, a lenient parse should be used; see [Lenient Parsing](tr35.md#Lenient_Parsing)._ As noted there, lenient parsing should ignore bidi format characters.
586*912701f9SAndroid Build Coastguard Worker
587*912701f9SAndroid Build Coastguard Worker### <a name="Special_Pattern_Characters" href="#Special_Pattern_Characters">Special Pattern Characters</a>
588*912701f9SAndroid Build Coastguard Worker
589*912701f9SAndroid Build Coastguard WorkerMany characters in a pattern are taken literally; they are matched during parsing and output unchanged during formatting. Special characters, on the other hand, stand for other characters, strings, or classes of characters. For example, the '#' character is replaced by a localized digit for the chosen numberSystem. Often the replacement character is the same as the pattern character; in the U.S. locale, the ',' grouping character is replaced by ','. However, the replacement is still happening, and if the symbols are modified, the grouping character changes. Some special characters affect the behavior of the formatter by their presence; for example, if the percent character is seen, then the value is multiplied by 100 before being displayed.
590*912701f9SAndroid Build Coastguard Worker
591*912701f9SAndroid Build Coastguard WorkerTo insert a special character in a pattern as a literal, that is, without any special meaning, the character must be quoted. There are some exceptions to this which are noted below. The Localized Replacement column shows the replacement from _[Number Symbols](#Number_Symbols)_ or the numberSystem's digits: _italic_ indicates a special function.
592*912701f9SAndroid Build Coastguard Worker
593*912701f9SAndroid Build Coastguard WorkerInvalid sequences of special characters (such as “¤¤¤¤¤¤” in current CLDR) should be handled for formatting and parsing as described in [Handling Invalid Patterns](tr35.md#Invalid_Patterns).
594*912701f9SAndroid Build Coastguard Worker
595*912701f9SAndroid Build Coastguard Worker###### Table: <a name="Number_Pattern_Character_Definitions" href="#Number_Pattern_Character_Definitions">Number Pattern Character Definitions</a>
596*912701f9SAndroid Build Coastguard Worker
597*912701f9SAndroid Build Coastguard Worker| Symbol | Location | Localized Replacement | Meaning |
598*912701f9SAndroid Build Coastguard Worker| :-- | :-- | :-- | :-- |
599*912701f9SAndroid Build Coastguard Worker| 0 | Number | digit | Digit |
600*912701f9SAndroid Build Coastguard Worker| 1-9 | Number | digit | '1' through '9' indicate rounding. |
601*912701f9SAndroid Build Coastguard Worker| @ | Number | digit | Significant digit |
602*912701f9SAndroid Build Coastguard Worker| # | Number | digit, _nothing_ | Digit, omitting leading/trailing zeros |
603*912701f9SAndroid Build Coastguard Worker| . | Number | decimal, currencyDecimal | Decimal separator or monetary decimal separator |
604*912701f9SAndroid Build Coastguard Worker| - | Number | minusSign, plusSign, approximatelySign | Minus sign. **Warning:** the pattern '-'0.0 is not the same as the pattern -0.0. In the former case, the minus sign is a literal. In the latter case, it is a special symbol, which is replaced by the minusSymbol, and can also be replaced by the plusSymbol for a format like +12% as in [Explicit Plus Signs](#Explicit_Plus). |
605*912701f9SAndroid Build Coastguard Worker| , | Number | group, currencyGroup | Grouping separator. May occur in both the integer part and the fractional part. The position determines the grouping. |
606*912701f9SAndroid Build Coastguard Worker| E | Number | exponential, superscriptingExponent | Separates mantissa and exponent in scientific notation. _Need not be quoted in prefix or suffix._ |
607*912701f9SAndroid Build Coastguard Worker| + | Exponent or Number (for explicit plus) | plusSign | Prefix positive exponents with localized plus sign. Used for explicit plus for numbers as well, as described in [Explicit Plus Signs](#Explicit_Plus). _Need not be quoted in prefix or suffix._ |
608*912701f9SAndroid Build Coastguard Worker| % | Prefix or suffix | percentSign | Multiply by 100 and show as percentage |
609*912701f9SAndroid Build Coastguard Worker| ‰ (U+2030) | Prefix or suffix | perMille | Multiply by 1000 and show as per mille (aka “basis points”) |
610*912701f9SAndroid Build Coastguard Worker| ; | Subpattern boundary | _syntax_ | Separates positive and negative subpatterns. When there is no explicit negative subpattern, an implicit negative subpattern is formed from the positive pattern with a prefixed - (ASCII U+002D HYPHEN-MINUS). |
611*912701f9SAndroid Build Coastguard Worker| ¤ (U+00A4) | Prefix or suffix | _currency symbol/name from currency specified in API_ | Any sequence is replaced by the localized currency symbol for the currency being formatted, as in the table below. If present in a pattern, the monetary decimal separator and grouping separators (if available) are used instead of the numeric ones. If data is unavailable for a given sequence in a given locale, the display may fall back to ¤ or ¤¤. See also the formatting for currency display names, steps 2 and 4 in [Currencies](#Currencies). <table><tr><th>No.</th><th>Replacement / Example</th></tr><tr><td rowspan="2">¤</td><td>Standard currency symbol</td></tr><tr><td>_C$12.00_</td></tr><tr><td rowspan="2">¤¤</td><td>ISO currency symbol (constant)</td></tr><tr><td>_CAD 12.00_</td></tr><tr><td rowspan="2">¤¤¤</td><td>Appropriate currency display name for the currency, based on the plural rules in effect for the locale</td></tr><tr><td>_5.00 Canadian dollars_</td></tr><tr><td rowspan="2" >¤¤¤¤¤</td><td>Narrow currency symbol. The same symbols may be used for multiple currencies. Thus the symbol may be ambiguous, and should only be where the context is clear.</td></tr><tr><td>_$12.00_</td></tr><tr><td>_others_</td><td>_Invalid in current CLDR. Reserved for future specification_</td></tr></table> |
612*912701f9SAndroid Build Coastguard Worker| * | Prefix or suffix boundary | _padding character specified in API_ | Pad escape, precedes pad character |
613*912701f9SAndroid Build Coastguard Worker| ' | Prefix or suffix | _syntax-only_ | Used to quote special characters in a prefix or suffix, for example, `"'#'#"` formats 123 to `"#123"`. To create a single quote itself, use two in a row: `"# o''clock"`. |
614*912701f9SAndroid Build Coastguard Worker
615*912701f9SAndroid Build Coastguard WorkerA pattern contains a positive subpattern and may contain a negative subpattern, for example, "#,##0.00;(#,##0.00)". Each subpattern has a prefix, a numeric part, and a suffix. If there is no explicit negative subpattern, the implicit negative subpattern is the ASCII minus sign (-) prefixed to the positive subpattern. That is, "0.00" alone is equivalent to "0.00;-0.00". (The data in CLDR is normalized to remove an explicit negative subpattern where it would be identical to the implicit form.)
616*912701f9SAndroid Build Coastguard Worker
617*912701f9SAndroid Build Coastguard WorkerNote that if a negative subpattern is used as-is: a minus sign is _not_ added, eg "0.00;0.00" ≠ "0.00;-0.00". Trailing semicolons are ignored, eg "0.00;" = "0.00". Whitespace is not ignored, including those around semicolons, so "0.00 ; -0.00" ≠ "0.00;-0.00".
618*912701f9SAndroid Build Coastguard Worker
619*912701f9SAndroid Build Coastguard WorkerIf there is an explicit negative subpattern, it serves only to specify the negative prefix and suffix; the number of digits, minimal digits, and other characteristics are ignored in the negative subpattern. That means that "#,##0.0#;(#)" has precisely the same result as "#,##0.0#;(#,##0.0#)". However in the CLDR data, the format is normalized so that the other characteristics are preserved, just for readability.
620*912701f9SAndroid Build Coastguard Worker
621*912701f9SAndroid Build Coastguard Worker> **Note:** The thousands separator and decimal separator in patterns are always ASCII ',' and '.'. They are substituted by the code with the correct local values according to other fields in CLDR. The same is true of the - (ASCII minus sign) and other special characters listed above.
622*912701f9SAndroid Build Coastguard Worker
623*912701f9SAndroid Build Coastguard WorkerA currency decimal pattern normally contains a currency symbol placeholder (¤, ¤¤, ¤¤¤, or ¤¤¤¤¤). The currency symbol placeholder may occur before the first digit, after the last digit symbol, or where the decimal symbol would otherwise be placed (for formats such as "12€50", as in "12€50 pour une omelette").
624*912701f9SAndroid Build Coastguard Worker
625*912701f9SAndroid Build Coastguard WorkerPlacement | Examples
626*912701f9SAndroid Build Coastguard Worker-------|-------
627*912701f9SAndroid Build Coastguard WorkerBefore|"¤#,##0.00" "¤ #,##0.00" "¤-#,##0.00" "¤ -#,##0.00" "-¤#,##0.00" "-¤ #,##0.00" …
628*912701f9SAndroid Build Coastguard WorkerAfter|"#,##0.00¤" "#,##0.00 ¤" "#,##0.00-¤" "#,##0.00- ¤" "#,##0.00¤-" "#,##0.00 ¤-" …
629*912701f9SAndroid Build Coastguard WorkerDecimal|"#,##0¤00"
630*912701f9SAndroid Build Coastguard Worker
631*912701f9SAndroid Build Coastguard WorkerBelow is a sample of patterns, special characters, and results:
632*912701f9SAndroid Build Coastguard Worker
633*912701f9SAndroid Build Coastguard Worker###### Table: <a name="Sample_Patterns_and_Results" href="#Sample_Patterns_and_Results">Sample Patterns and Results</a>
634*912701f9SAndroid Build Coastguard Worker
635*912701f9SAndroid Build Coastguard Worker<table><tbody>
636*912701f9SAndroid Build Coastguard Worker<tr><th>explicit pattern:</th><td colspan="2">0.00;-0.00</td><td colspan="2">0.00;0.00-</td><td colspan="2">0.00+;0.00-</td></tr>
637*912701f9SAndroid Build Coastguard Worker<tr><th>decimalSign:</th><td colspan="2">,</td><td colspan="2">,</td><td colspan="2">,</td></tr>
638*912701f9SAndroid Build Coastguard Worker<tr><th>minusSign:</th><td colspan="2">∸</td><td colspan="2">∸</td><td colspan="2">∸</td></tr>
639*912701f9SAndroid Build Coastguard Worker<tr><th>plusSign:</th><td colspan="2">∔</td><td colspan="2">∔</td><td colspan="2">∔</td></tr>
640*912701f9SAndroid Build Coastguard Worker<tr><th>number:</th><td>3.1415</td><td>-3.1415</td><td>3.1415</td><td>-3.1415</td><td>3.1415</td><td>-3.1415</td></tr>
641*912701f9SAndroid Build Coastguard Worker<tr><th>formatted:</th><td>3,14</td><td>∸3,14</td><td>3,14</td><td>3,14∸</td><td>3,14∔</td><td>3,14∸</td></tr>
642*912701f9SAndroid Build Coastguard Worker</tbody></table>
643*912701f9SAndroid Build Coastguard Worker
644*912701f9SAndroid Build Coastguard Worker_In the above table, ∸ = U+2238 DOT MINUS and ∔ = U+2214 DOT PLUS are used for illustration._
645*912701f9SAndroid Build Coastguard Worker
646*912701f9SAndroid Build Coastguard WorkerThe prefixes, suffixes, and various symbols used for infinity, digits, thousands separators, decimal separators, and so on may be set to arbitrary values, and they will appear properly during formatting. _However, care must be taken that the symbols and strings do not conflict, or parsing will be unreliable._ For example, either the positive and negative prefixes or the suffixes must be distinct for any parser using this data to be able to distinguish positive from negative values. Another example is that the decimal separator and thousands separator should be distinct characters, or parsing will be impossible.
647*912701f9SAndroid Build Coastguard Worker
648*912701f9SAndroid Build Coastguard WorkerThe _grouping separator_ is a character that separates clusters of integer digits to make large numbers more legible. It is commonly used for thousands, but in some locales it separates ten-thousands. The _grouping size_ is the number of digits between the grouping separators, such as 3 for "100,000,000" or 4 for "1 0000 0000". There are actually two different grouping sizes: One used for the least significant integer digits, the _primary grouping size_, and one used for all others, the _secondary grouping size_. In most locales these are the same, but sometimes they are different. For example, if the primary grouping interval is 3, and the secondary is 2, then this corresponds to the pattern "#,##,##0", and the number 123456789 is formatted as "12,34,56,789". If a pattern contains multiple grouping separators, the interval between the last one and the end of the integer defines the primary grouping size, and the interval between the last two defines the secondary grouping size. All others are ignored, so "#,##,###,####" == "###,###,####" == "##,#,###,####".
649*912701f9SAndroid Build Coastguard Worker
650*912701f9SAndroid Build Coastguard WorkerThe grouping separator may also occur in the fractional part, such as in “#,##0.###,#”. This is most commonly done where the grouping separator character is a thin, non-breaking space (U+202F), such as “1.618 033 988 75”. See [physics.nist.gov/cuu/Units/checklist.html](https://physics.nist.gov/cuu/Units/checklist.html).
651*912701f9SAndroid Build Coastguard Worker
652*912701f9SAndroid Build Coastguard WorkerFor consistency in the CLDR data, the following conventions are observed:
653*912701f9SAndroid Build Coastguard Worker
654*912701f9SAndroid Build Coastguard Worker* All number patterns should be minimal: there should be no leading # marks except to specify the position of the grouping separators (for example, avoid  ##,##0.###).
655*912701f9SAndroid Build Coastguard Worker* All formats should have one 0 before the decimal point (for example, avoid #,###.##)
656*912701f9SAndroid Build Coastguard Worker* Decimal formats should have three hash marks in the fractional position (for example, #,##0.###).
657*912701f9SAndroid Build Coastguard Worker* Currency formats should have two zeros in the fractional position (for example, ¤ #,##0.00).
658*912701f9SAndroid Build Coastguard Worker    * The exact number of decimals is overridden with the decimal count in supplementary data or by API settings.
659*912701f9SAndroid Build Coastguard Worker* The only time two thousands separators need to be used is when the number of digits varies, such as for Hindi: #,##,##0.
660*912701f9SAndroid Build Coastguard Worker* The **minimumGroupingDigits** can be used to suppress groupings below a certain value. This is used for languages such as Polish, where one would only write the grouping separator for values above 9999. The minimumGroupingDigits contains the default for the locale.
661*912701f9SAndroid Build Coastguard Worker    * The attribute value is used by adding it to the grouping separator value. If the input number has fewer integer digits, the grouping separator is suppressed.
662*912701f9SAndroid Build Coastguard Worker    * ##### <a name="Examples_of_minimumGroupingDigits" href="#Examples_of_minimumGroupingDigits">Examples of minimumGroupingDigits</a>
663*912701f9SAndroid Build Coastguard Worker
664*912701f9SAndroid Build Coastguard Worker        | minimum­GroupingDigits | Pattern Grouping | Input Number | Formatted |
665*912701f9SAndroid Build Coastguard Worker        | ---: | ---: | ---: | ---: |
666*912701f9SAndroid Build Coastguard Worker        | 1 | 3 | 1000 | 1,000 |
667*912701f9SAndroid Build Coastguard Worker        | 1 | 3 | 10000 | 10,000 |
668*912701f9SAndroid Build Coastguard Worker        | 2 | 3 | 1000 | 1000 |
669*912701f9SAndroid Build Coastguard Worker        | 2 | 3 | 10000 | 10,000 |
670*912701f9SAndroid Build Coastguard Worker        | 1 | 4 | 10000 | 1,0000 |
671*912701f9SAndroid Build Coastguard Worker        | 2 | 4 | 10000 | 10000 |
672*912701f9SAndroid Build Coastguard Worker
673*912701f9SAndroid Build Coastguard Worker#### <a name="Explicit_Plus" href="#Explicit_Plus">Explicit Plus Signs</a>
674*912701f9SAndroid Build Coastguard Worker
675*912701f9SAndroid Build Coastguard WorkerAn explicit "plus" format can be formed, so as to show a visible + sign when formatting a non-negative number. The displayed plus sign can be an ASCII plus or another character, such as + U+FF0B FULLWIDTH PLUS SIGN or ➕ U+2795 HEAVY PLUS SIGN; it is taken from whatever is set for plusSign in _[Number Symbols](#Number_Symbols)_.
676*912701f9SAndroid Build Coastguard Worker
677*912701f9SAndroid Build Coastguard Worker1. Get the negative subpattern (explicit or implicit).
678*912701f9SAndroid Build Coastguard Worker2. Replace any unquoted ASCII minus sign by an ASCII plus sign.
679*912701f9SAndroid Build Coastguard Worker3. If there are any replacements, use that for the positive subpattern.
680*912701f9SAndroid Build Coastguard Worker
681*912701f9SAndroid Build Coastguard WorkerFor an example, see [Sample Patterns and Results](#Sample_Patterns_and_Results).
682*912701f9SAndroid Build Coastguard Worker
683*912701f9SAndroid Build Coastguard Worker### <a name="Formatting" href="#Formatting">Formatting</a>
684*912701f9SAndroid Build Coastguard Worker
685*912701f9SAndroid Build Coastguard WorkerFormatting is guided by several parameters, all of which can be specified either using a pattern or using an external API designed for number formatting. The following description applies to formats that do not use [scientific notation](#sci) or [significant digits](#sigdig).
686*912701f9SAndroid Build Coastguard Worker
687*912701f9SAndroid Build Coastguard Worker* If the number of actual integer digits exceeds the _maximum integer digits_, then only the least significant digits are shown. For example, 1997 is formatted as "97" if the maximum integer digits is set to 2.
688*912701f9SAndroid Build Coastguard Worker* If the number of actual integer digits is less than the _minimum integer digits_, then leading zeros are added. For example, 1997 is formatted as "01997" if the minimum integer digits is set to 5.
689*912701f9SAndroid Build Coastguard Worker* If the number of actual fraction digits exceeds the _maximum fraction digits_, then half-even rounding it performed to the maximum fraction digits. For example, 0.125 is formatted as "0.12" if the maximum fraction digits is 2. This behavior can be changed by specifying a rounding increment and a rounding mode.
690*912701f9SAndroid Build Coastguard Worker* If the number of actual fraction digits is less than the _minimum fraction digits_, then trailing zeros are added. For example, 0.125 is formatted as "0.1250" if the minimum fraction digits is set to 4.
691*912701f9SAndroid Build Coastguard Worker* Trailing fractional zeros are not displayed if they occur _j_ positions after the decimal, where _j_ is less than the maximum fraction digits. For example, 0.10004 is formatted as "0.1" if the maximum fraction digits is four or less.
692*912701f9SAndroid Build Coastguard Worker
693*912701f9SAndroid Build Coastguard Worker**Special Values**
694*912701f9SAndroid Build Coastguard Worker
695*912701f9SAndroid Build Coastguard Worker`NaN` is represented as a single character, typically `(U+FFFD)` . This character is determined by the localized number symbols. This is the only value for which the prefixes and suffixes are not used.
696*912701f9SAndroid Build Coastguard Worker
697*912701f9SAndroid Build Coastguard WorkerInfinity is represented as a single character, typically ∞ `(U+221E)` , with the positive or negative prefixes and suffixes applied. The infinity character is determined by the localized number symbols.
698*912701f9SAndroid Build Coastguard Worker
699*912701f9SAndroid Build Coastguard Worker### <a name="sci" href="#sci">Scientific Notation</a>
700*912701f9SAndroid Build Coastguard Worker
701*912701f9SAndroid Build Coastguard WorkerNumbers in scientific notation are expressed as the product of a mantissa and a power of ten, for example, 1234 can be expressed as 1.234 x 10<sup>3</sup>. The mantissa is typically in the half-open interval [1.0, 10.0) or sometimes [0.0, 1.0), but it need not be. In a pattern, the exponent character immediately followed by one or more digit characters indicates scientific notation. Example: "0.###E0" formats the number 1234 as "1.234E3".
702*912701f9SAndroid Build Coastguard Worker
703*912701f9SAndroid Build Coastguard Worker* The number of digit characters after the exponent character gives the minimum exponent digit count. There is no maximum. Negative exponents are formatted using the localized minus sign, _not_ the prefix and suffix from the pattern. This allows patterns such as "0.###E0 m/s". To prefix positive exponents with a localized plus sign, specify '+' between the exponent and the digits: "0.###E+0" will produce formats "1E+1", "1E+0", "1E-1", and so on. (In localized patterns, use the localized plus sign rather than '+'.)
704*912701f9SAndroid Build Coastguard Worker* The minimum number of integer digits is achieved by adjusting the exponent. Example: 0.00123 formatted with "00.###E0" yields "12.3E-4". This only happens if there is no maximum number of integer digits. If there is a maximum, then the minimum number of integer digits is fixed at one.
705*912701f9SAndroid Build Coastguard Worker* The maximum number of integer digits, if present, specifies the exponent grouping. The most common use of this is to generate _engineering notation_, in which the exponent is a multiple of three, for example, "##0.###E0". The number 12345 is formatted using "##0.####E0" as "12.345E3".
706*912701f9SAndroid Build Coastguard Worker* When using scientific notation, the formatter controls the digit counts using logic for significant digits. The maximum number of significant digits comes from the mantissa portion of the pattern: the string of #, 0, and period (".") characters immediately preceding the E. To get the maximum number of significant digits, use the following algorithm:
707*912701f9SAndroid Build Coastguard Worker
708*912701f9SAndroid Build Coastguard Worker    1.  If the mantissa pattern contains a period:
709*912701f9SAndroid Build Coastguard Worker        1.  If the mantissa pattern contains at least one 0:
710*912701f9SAndroid Build Coastguard Worker            *   Return the number of 0s before the period added to the number of #s or 0s after the period
711*912701f9SAndroid Build Coastguard Worker        2.  Else:
712*912701f9SAndroid Build Coastguard Worker            *   Return 1 plus the number of #s after the period
713*912701f9SAndroid Build Coastguard Worker    2.  Else:
714*912701f9SAndroid Build Coastguard Worker        1.  If the mantissa pattern contains at least one 0:
715*912701f9SAndroid Build Coastguard Worker            *   Return the number of 0s.
716*912701f9SAndroid Build Coastguard Worker        2.  Else:
717*912701f9SAndroid Build Coastguard Worker            *   Return positive infinity.
718*912701f9SAndroid Build Coastguard Worker
719*912701f9SAndroid Build Coastguard Worker    Examples:
720*912701f9SAndroid Build Coastguard Worker
721*912701f9SAndroid Build Coastguard Worker    *   0.##E0 means a max of 3 significant digits.
722*912701f9SAndroid Build Coastguard Worker    *   #.##E0 also means a max of 3 significant digits.
723*912701f9SAndroid Build Coastguard Worker    *   #.0#E0 means a max of 2 significant digits.
724*912701f9SAndroid Build Coastguard Worker    *   0E0 means a max of 1 significant digit.
725*912701f9SAndroid Build Coastguard Worker    *   #E0 means infinite precision.
726*912701f9SAndroid Build Coastguard Worker    *   ###E0 means engineering notation with infinite precision.
727*912701f9SAndroid Build Coastguard Worker*   Exponential patterns may not contain grouping separators.
728*912701f9SAndroid Build Coastguard Worker
729*912701f9SAndroid Build Coastguard Worker### <a name="sigdig" href="#sigdig">Significant Digits</a>
730*912701f9SAndroid Build Coastguard Worker
731*912701f9SAndroid Build Coastguard WorkerThere are two ways of controlling how many digits are shown: (a) significant digits counts, or (b) integer and fraction digit counts. Integer and fraction digit counts are described above. When a formatter is using significant digits counts, it uses however many integer and fraction digits are required to display the specified number of significant digits. It may ignore min/max integer/fraction digits, or it may use them to the extent possible.
732*912701f9SAndroid Build Coastguard Worker
733*912701f9SAndroid Build Coastguard Worker###### Table: <a name="Significant_Digits_Examples" href="#Significant_Digits_Examples">Significant Digits Examples</a>
734*912701f9SAndroid Build Coastguard Worker
735*912701f9SAndroid Build Coastguard Worker| Pattern | Minimum significant digits | Maximum significant digits | Number | Output |
736*912701f9SAndroid Build Coastguard Worker| :-- | :-- | :-- | :-- | :-- |
737*912701f9SAndroid Build Coastguard Worker| `@@@` | 3 | 3 | 12345 | `12300` |
738*912701f9SAndroid Build Coastguard Worker| `@@@` | 3 | 3 | 0.12345 | `0.123` |
739*912701f9SAndroid Build Coastguard Worker| `@@##` | 2 | 4 | 3.14159 | `3.142` |
740*912701f9SAndroid Build Coastguard Worker| `@@##` | 2 | 4 | 1.23004 | `1.23` |
741*912701f9SAndroid Build Coastguard Worker
742*912701f9SAndroid Build Coastguard Worker* In order to enable significant digits formatting, use a pattern containing the `'@'` pattern character. In order to disable significant digits formatting, use a pattern that does not contain the `'@'` pattern character.
743*912701f9SAndroid Build Coastguard Worker* Significant digit counts may be expressed using patterns that specify a minimum and maximum number of significant digits. These are indicated by the `'@'` and `'#'` characters. The minimum number of significant digits is the number of `'@'` characters. The maximum number of significant digits is the number of `'@'` characters plus the number of `'#'` characters following on the right. For example, the pattern `"@@@"` indicates exactly 3 significant digits. The pattern `"@##"` indicates from 1 to 3 significant digits. Trailing zero digits to the right of the decimal separator are suppressed after the minimum number of significant digits have been shown. For example, the pattern `"@##"` formats the number 0.1203 as `"0.12"`.
744*912701f9SAndroid Build Coastguard Worker* Implementations may forbid the use of significant digits in combination with min/max integer/fraction digits. In such a case, if a pattern uses significant digits, it may not contain a decimal separator, nor the `'0'` pattern character. Patterns such as `"@00"` or `"@.###"` would be disallowed.
745*912701f9SAndroid Build Coastguard Worker* Any number of `'#'` characters may be prepended to the left of the leftmost `'@'` character. These have no effect on the minimum and maximum significant digits counts, but may be used to position grouping separators. For example, `"#,#@#"` indicates a minimum of one significant digit, a maximum of two significant digits, and a grouping size of three.
746*912701f9SAndroid Build Coastguard Worker* The number of significant digits has no effect on parsing.
747*912701f9SAndroid Build Coastguard Worker* Significant digits may be used together with exponential notation. Such patterns are equivalent to a normal exponential pattern with a minimum and maximum integer digit count of one, a minimum fraction digit count of `Minimum Significant Digits - 1`, and a maximum fraction digit count of `Maximum Significant Digits - 1`. For example, the pattern `"@@###E0"` is equivalent to `"0.0###E0"`.
748*912701f9SAndroid Build Coastguard Worker
749*912701f9SAndroid Build Coastguard Worker### <a name="Padding" href="#Padding">Padding</a>
750*912701f9SAndroid Build Coastguard Worker
751*912701f9SAndroid Build Coastguard WorkerPatterns support padding the result to a specific width. In a pattern the pad escape character, followed by a single pad character, causes padding to be parsed and formatted. The pad escape character is '*'. For example, `"$*x#,##0.00"` formats 123 to `"$xx123.00"` , and 1234 to `"$1,234.00"` .
752*912701f9SAndroid Build Coastguard Worker
753*912701f9SAndroid Build Coastguard Worker* When padding is in effect, the width of the positive subpattern, including prefix and suffix, determines the format width. For example, in the pattern `"* #0 o''clock"`, the format width is 10.
754*912701f9SAndroid Build Coastguard Worker* Some parameters which usually do not matter have meaning when padding is used, because the pattern width is significant with padding. In the pattern "* ##,##,#,##0.##", the format width is 14. The initial characters "##,##," do not affect the grouping size or maximum integer digits, but they do affect the format width.
755*912701f9SAndroid Build Coastguard Worker* Padding may be inserted at one of four locations: before the prefix, after the prefix, before the suffix, or after the suffix. No padding can be specified in any other location. If there is no prefix, before the prefix and after the prefix are equivalent, likewise for the suffix.
756*912701f9SAndroid Build Coastguard Worker* When specified in a pattern, the code point immediately following the pad escape is the pad character. This may be any character, including a special pattern character. That is, the pad escape _escapes_ the following character. If there is no character after the pad escape, then the pattern is illegal.
757*912701f9SAndroid Build Coastguard Worker
758*912701f9SAndroid Build Coastguard Worker### <a name="Rounding" href="#Rounding">Rounding</a>
759*912701f9SAndroid Build Coastguard Worker
760*912701f9SAndroid Build Coastguard WorkerPatterns support rounding to a specific increment. For example, 1230 rounded to the nearest 50 is 1250. Mathematically, rounding to specific increments is performed by dividing by the increment, rounding to an integer, then multiplying by the increment. To take a more bizarre example, 1.234 rounded to the nearest 0.65 is 1.3, as follows:
761*912701f9SAndroid Build Coastguard Worker
762*912701f9SAndroid Build Coastguard Worker<table><tbody>
763*912701f9SAndroid Build Coastguard Worker<tr><th>Original:</th><td>1.234</td></tr>
764*912701f9SAndroid Build Coastguard Worker<tr><th>Divide by increment (0.65):</th><td>1.89846…</td></tr>
765*912701f9SAndroid Build Coastguard Worker<tr><th>Round:</th><td>2</td></tr>
766*912701f9SAndroid Build Coastguard Worker<tr><th>Multiply by increment (0.65):</th><td>1.3</td></tr>
767*912701f9SAndroid Build Coastguard Worker</tbody></table>
768*912701f9SAndroid Build Coastguard Worker
769*912701f9SAndroid Build Coastguard WorkerTo specify a rounding increment in a pattern, include the increment in the pattern itself. "#,#50" specifies a rounding increment of 50. "#,##0.05" specifies a rounding increment of 0.05.
770*912701f9SAndroid Build Coastguard Worker
771*912701f9SAndroid Build Coastguard Worker* Rounding only affects the string produced by formatting. It does not affect parsing or change any numerical values.
772*912701f9SAndroid Build Coastguard Worker* An implementation may allow the specification of a _rounding mode_ to determine how values are rounded. In the absence of such choices, the default is to round "half-even", as described in IEEE arithmetic. That is, it rounds towards the "nearest neighbor" unless both neighbors are equidistant, in which case, it rounds towards the even neighbor. Behaves as for round "half-up" if the digit to the left of the discarded fraction is odd; behaves as for round "half-down" if it's even. Note that this is the rounding mode that minimizes cumulative error when applied repeatedly over a sequence of calculations.
773*912701f9SAndroid Build Coastguard Worker* Some locales use rounding in their currency formats to reflect the smallest currency denomination.
774*912701f9SAndroid Build Coastguard Worker* In a pattern, digits '1' through '9' specify rounding, but otherwise behave identically to digit '0'.
775*912701f9SAndroid Build Coastguard Worker
776*912701f9SAndroid Build Coastguard Worker### <a name="Quoting_Rules" href="#Quoting_Rules">Quoting Rules</a>
777*912701f9SAndroid Build Coastguard Worker
778*912701f9SAndroid Build Coastguard WorkerSingle quotes (**'**) enclose bits of the pattern that should be treated literally. Inside a quoted string, two single quotes ('') are replaced with a single one ('). For example: `'X '`#`' Q '` -> **X 1939 Q** (Literal strings `shaded`.)
779*912701f9SAndroid Build Coastguard Worker
780*912701f9SAndroid Build Coastguard Worker## <a name="Currencies" href="#Currencies">Currencies</a>
781*912701f9SAndroid Build Coastguard Worker
782*912701f9SAndroid Build Coastguard Worker```xml
783*912701f9SAndroid Build Coastguard Worker<!ELEMENT currencies (alias | (default?, currency*, special*)) >
784*912701f9SAndroid Build Coastguard Worker<!ELEMENT currency (alias | (((pattern+, displayName*, symbol*) | (displayName+, symbol*, pattern*) | (symbol+, pattern*))?, decimal*, group*, special*)) >
785*912701f9SAndroid Build Coastguard Worker<!ELEMENT symbol ( #PCDATA ) >
786*912701f9SAndroid Build Coastguard Worker<!ATTLIST symbol choice ( true | false ) #IMPLIED > <!-- deprecated -->
787*912701f9SAndroid Build Coastguard Worker```
788*912701f9SAndroid Build Coastguard Worker
789*912701f9SAndroid Build Coastguard Worker> **Note:** The term "pattern" appears twice in the above. The first is for consistency with all other cases of pattern + displayName; the second is for backwards compatibility.
790*912701f9SAndroid Build Coastguard Worker
791*912701f9SAndroid Build Coastguard Worker```xml
792*912701f9SAndroid Build Coastguard Worker<currencies>
793*912701f9SAndroid Build Coastguard Worker    <currency type="USD">
794*912701f9SAndroid Build Coastguard Worker        <displayName>Dollar</displayName>
795*912701f9SAndroid Build Coastguard Worker        <symbol>$</symbol>
796*912701f9SAndroid Build Coastguard Worker    </currency>
797*912701f9SAndroid Build Coastguard Worker    <currency type ="JPY">
798*912701f9SAndroid Build Coastguard Worker        <displayName>Yen</displayName>
799*912701f9SAndroid Build Coastguard Worker        <symbol>¥</symbol>
800*912701f9SAndroid Build Coastguard Worker    </currency>
801*912701f9SAndroid Build Coastguard Worker    <currency type="PTE">
802*912701f9SAndroid Build Coastguard Worker        <displayName>Escudo</displayName>
803*912701f9SAndroid Build Coastguard Worker        <symbol>$</symbol>
804*912701f9SAndroid Build Coastguard Worker    </currency>
805*912701f9SAndroid Build Coastguard Worker</currencies>
806*912701f9SAndroid Build Coastguard Worker```
807*912701f9SAndroid Build Coastguard Worker
808*912701f9SAndroid Build Coastguard WorkerIn formatting currencies, the currency number format is used with the appropriate symbol from `<currencies>`, according to the currency code. The `<currencies>` list can contain codes that are no longer in current use, such as PTE. The `choice` attribute has been deprecated.
809*912701f9SAndroid Build Coastguard Worker
810*912701f9SAndroid Build Coastguard WorkerThe `count` attribute distinguishes the different plural forms, such as in the following:
811*912701f9SAndroid Build Coastguard Worker
812*912701f9SAndroid Build Coastguard Worker```xml
813*912701f9SAndroid Build Coastguard Worker<currencyFormats>
814*912701f9SAndroid Build Coastguard Worker    <unitPattern count="other">{0} {1}</unitPattern>
815*912701f9SAndroid Build Coastguard Worker816*912701f9SAndroid Build Coastguard Worker<currencies>
817*912701f9SAndroid Build Coastguard Worker```
818*912701f9SAndroid Build Coastguard Worker
819*912701f9SAndroid Build Coastguard Worker```xml
820*912701f9SAndroid Build Coastguard Worker<currency type="ZWD">
821*912701f9SAndroid Build Coastguard Worker    <displayName>Zimbabwe Dollar</displayName>
822*912701f9SAndroid Build Coastguard Worker    <displayName count="one">Zimbabwe dollar</displayName>
823*912701f9SAndroid Build Coastguard Worker    <displayName count="other">Zimbabwe dollars</displayName>
824*912701f9SAndroid Build Coastguard Worker    <symbol>Z$</symbol>
825*912701f9SAndroid Build Coastguard Worker</currency>
826*912701f9SAndroid Build Coastguard Worker```
827*912701f9SAndroid Build Coastguard Worker
828*912701f9SAndroid Build Coastguard WorkerNote on displayNames:
829*912701f9SAndroid Build Coastguard Worker* In general the region portion of the displayName should match the territory name, see **Part 2** _[Locale Display Name Fields](tr35-general.md#locale_display_name_fields)_.
830*912701f9SAndroid Build Coastguard Worker* As a result, the English currency displayName in CLDR may not match the name in ISO 4217.
831*912701f9SAndroid Build Coastguard Worker
832*912701f9SAndroid Build Coastguard WorkerTo format a particular currency value "ZWD" for a particular numeric value _n_ using the (long) display name:
833*912701f9SAndroid Build Coastguard Worker
834*912701f9SAndroid Build Coastguard Worker1. If the numeric value is exactly 0 or 1, first see if there is a count with a matching explicit number (0 or 1). If so, use that string (see [Explicit 0 and 1 rules](#Explicit_0_1_rules)).
835*912701f9SAndroid Build Coastguard Worker2. Otherwise, determine the `count` value that corresponds to _n_ using the rules in _[- Language Plural Rules](#Language_Plural_Rules)_
836*912701f9SAndroid Build Coastguard Worker3. Next, get the currency unitPattern.
837*912701f9SAndroid Build Coastguard Worker   1. Look for a `unitPattern` element that matches the `count` value, starting in the current locale and then following the locale fallback chain up to, but not including root.
838*912701f9SAndroid Build Coastguard Worker   2. If no matching `unitPattern` element was found in the previous step, then look for a `unitPattern` element that matches `count="other"`, starting in the current locale and then following the locale fallback chain up to root (which has a `unitPattern` element with `count="other"` for every unit type).
839*912701f9SAndroid Build Coastguard Worker   3. The resulting unitPattern element indicates the appropriate positioning of the numeric value and the currency display name.
840*912701f9SAndroid Build Coastguard Worker4. Next, get the `displayName` element for the currency.
841*912701f9SAndroid Build Coastguard Worker   1. Look for a `displayName` element that matches the `count` value, starting in the current locale and then following the locale fallback chain up to, but not including root.
842*912701f9SAndroid Build Coastguard Worker   2. If no matching `displayName` element was found in the previous step, then look for a `displayName` element that matches `count="other"`, starting in the current locale and then following the locale fallback chain up to, but not including root.
843*912701f9SAndroid Build Coastguard Worker   3. If no matching `displayName` element was found in the previous step, then look for a `displayName` element with no count, starting in the current locale and then following the locale fallback chain up to root.
844*912701f9SAndroid Build Coastguard Worker   4. If there is no `displayName` element, use the currency code itself (for example, "ZWD").
845*912701f9SAndroid Build Coastguard Worker5. Format the numeric value according to the locale. Use the locale’s `<decimalFormats …>` pattern, not the `<currencyFormats>` pattern that is used with the symbol (eg, Z$). As when formatting symbol currency values, reset the number of decimals according to the supplemental `<currencyData>` and use the currencyDecimal symbol if different from the decimal symbol.
846*912701f9SAndroid Build Coastguard Worker   1. The number of decimals should be overridable in an API, so that clients can choose between “2 US dollars” and “2.00 US dollars”.
847*912701f9SAndroid Build Coastguard Worker6. Substitute the formatted numeric value for the {0} in the `unitPattern`, and the currency display name for the {1}.
848*912701f9SAndroid Build Coastguard Worker
849*912701f9SAndroid Build Coastguard WorkerWhile for English this may seem overly complex, for some other languages different plural forms are used for different unit types; the plural forms for certain unit types may not use all of the plural-form tags defined for the language.
850*912701f9SAndroid Build Coastguard Worker
851*912701f9SAndroid Build Coastguard WorkerFor example, if the currency is ZWD and the number is 1234, then the latter maps to `count="other"` for English. The unit pattern for that is "{0} {1}", and the display name is "Zimbabwe dollars". The final formatted number is then "1,234 Zimbabwe dollars".
852*912701f9SAndroid Build Coastguard Worker
853*912701f9SAndroid Build Coastguard Worker---
854*912701f9SAndroid Build Coastguard Worker
855*912701f9SAndroid Build Coastguard WorkerWhen a currency symbol is substitited into a pattern, some spacing adjustments or other adjustments may be necessary depending on the nature of the symbol. In CLDR 42 and later, the preferred way to handle this is via the `alt="alphaNextToNumber"` variant of the `currencyFormat` `pattern`, as described in _[Section 2.4.2: Currency Formats](#Currency_Formats)_. In earlier versions of CLDR this was handled via the `currencySpacing` element as described below. This element is still present in CLDR 42 and its use is described below for implementations that may not yet support the `alt="alphaNextToNumber"` variant of the `currencyFormat` `pattern`.
856*912701f9SAndroid Build Coastguard Worker
857*912701f9SAndroid Build Coastguard Worker```xml
858*912701f9SAndroid Build Coastguard Worker<currencySpacing>
859*912701f9SAndroid Build Coastguard Worker  <beforeCurrency>
860*912701f9SAndroid Build Coastguard Worker    <currencyMatch>[:^S:]</currencyMatch>
861*912701f9SAndroid Build Coastguard Worker    <surroundingMatch>[:digit:]</surroundingMatch>
862*912701f9SAndroid Build Coastguard Worker    <insertBetween> </insertBetween>
863*912701f9SAndroid Build Coastguard Worker  </beforeCurrency>
864*912701f9SAndroid Build Coastguard Worker  <afterCurrency>
865*912701f9SAndroid Build Coastguard Worker    <currencyMatch>[:^S:]</currencyMatch>
866*912701f9SAndroid Build Coastguard Worker    <surroundingMatch>[:digit:]</surroundingMatch>
867*912701f9SAndroid Build Coastguard Worker    <insertBetween> </insertBetween>
868*912701f9SAndroid Build Coastguard Worker  </afterCurrency>
869*912701f9SAndroid Build Coastguard Worker</currencySpacing>
870*912701f9SAndroid Build Coastguard Worker```
871*912701f9SAndroid Build Coastguard Worker
872*912701f9SAndroid Build Coastguard WorkerThis element controls whether additional characters are inserted on the boundary between the symbol and the pattern. For example, with the above `currencySpacing`, inserting the symbol "US$" into the pattern "#,##0.00¤" would result in an extra _no-break space_ inserted before the symbol, for example, "#,##0.00 US$". The `beforeCurrency` element governs this case, since we are looking _before_ the "¤" symbol. The `currencyMatch` is positive, since the "U" in "US$" is at the start of the currency symbol being substituted. The `surroundingMatch` is positive, since the character just before the "¤" will be a digit. Because these two conditions are true, the insertion is made.
873*912701f9SAndroid Build Coastguard Worker
874*912701f9SAndroid Build Coastguard WorkerConversely, look at the pattern "¤#,##0.00" with the symbol "US$". In this case, there is no insertion; the result is simply "US$#,##0.00". The `afterCurrency` element governs this case, since we are looking _after_ the "¤" symbol. The `surroundingMatch` is positive, since the character just after the "¤" will be a digit. However, the `currencyMatch` is **not** positive, since the "\$" in "US\$" is at the end of the currency symbol being substituted. So the insertion is not made.
875*912701f9SAndroid Build Coastguard Worker
876*912701f9SAndroid Build Coastguard WorkerFor more information on the matching used in the `currencyMatch` and `surroundingMatch` elements, see the main document _[Appendix E: Unicode Sets](tr35.md#Unicode_Sets)_.
877*912701f9SAndroid Build Coastguard Worker
878*912701f9SAndroid Build Coastguard Worker---
879*912701f9SAndroid Build Coastguard Worker
880*912701f9SAndroid Build Coastguard WorkerCurrencies can also contain optional grouping, decimal data, and pattern elements. This data is inherited from the `<symbols>` in the same locale data (if not present in the chain up to root), so only the _differing_ data will be present. See the main document _[Multiple Inheritance](tr35.md#Multiple_Inheritance)_.
881*912701f9SAndroid Build Coastguard Worker
882*912701f9SAndroid Build Coastguard Worker> **Note:** _Currency values should **never** be interchanged without a known currency code. You never want the number 3.5 interpreted as $3.50 by one user and €3.50 by another._ Locale data contains localization information for currencies, not a currency value for a country. A currency amount logically consists of a numeric value, plus an accompanying currency code (or equivalent). The currency code may be implicit in a protocol, such as where USD is implicit. But if the raw numeric value is transmitted without any context, then it has no definitive interpretation.
883*912701f9SAndroid Build Coastguard Worker
884*912701f9SAndroid Build Coastguard WorkerNotice that the currency code is completely independent of the end-user's language or locale. For example, BGN is the code for Bulgarian Lev. A currency amount of <BGN, 1.23456×10³> would be localized for a Bulgarian user into "1 234,56 лв." (using Cyrillic letters). For an English user it would be localized into the string "BGN 1,234.56". The end-user's language is needed for doing this last localization step; but that language is completely orthogonal to the currency code needed in the data. After all, the same English user could be working with dozens of currencies. Notice also that the currency code is also independent of whether currency values are inter-converted, which requires more interesting financial processing: the rate of conversion may depend on a variety of factors.
885*912701f9SAndroid Build Coastguard Worker
886*912701f9SAndroid Build Coastguard WorkerThus logically speaking, once a currency amount is entered into a system, it should be logically accompanied by a currency code in all processing. This currency code is independent of whatever the user's original locale was. Only in badly-designed software is the currency code (or equivalent) not present, so that the software has to "guess" at the currency code based on the user's locale.
887*912701f9SAndroid Build Coastguard Worker
888*912701f9SAndroid Build Coastguard Worker> **Note:** The number of decimal places **and** the rounding for each currency is not locale-specific data, and is not contained in the Locale Data Markup Language format. Those values override whatever is given in the currency numberFormat. For more information, see _[Supplemental Currency Data](#Supplemental_Currency_Data)_.
889*912701f9SAndroid Build Coastguard Worker
890*912701f9SAndroid Build Coastguard WorkerFor background information on currency names, see [[CurrencyInfo](tr35.md#CurrencyInfo)].
891*912701f9SAndroid Build Coastguard Worker
892*912701f9SAndroid Build Coastguard Worker### <a name="Supplemental_Currency_Data" href="#Supplemental_Currency_Data">Supplemental Currency Data</a>
893*912701f9SAndroid Build Coastguard Worker
894*912701f9SAndroid Build Coastguard Worker```xml
895*912701f9SAndroid Build Coastguard Worker<!ELEMENT currencyData ( fractions*, region+ ) >
896*912701f9SAndroid Build Coastguard Worker<!ELEMENT fractions ( info+ ) >
897*912701f9SAndroid Build Coastguard Worker
898*912701f9SAndroid Build Coastguard Worker<!ELEMENT info EMPTY >
899*912701f9SAndroid Build Coastguard Worker<!ATTLIST info iso4217 NMTOKEN #REQUIRED >
900*912701f9SAndroid Build Coastguard Worker<!ATTLIST info digits NMTOKEN #IMPLIED >
901*912701f9SAndroid Build Coastguard Worker<!ATTLIST info rounding NMTOKEN #IMPLIED >
902*912701f9SAndroid Build Coastguard Worker<!ATTLIST info cashDigits NMTOKEN #IMPLIED >
903*912701f9SAndroid Build Coastguard Worker<!ATTLIST info cashRounding NMTOKEN #IMPLIED >
904*912701f9SAndroid Build Coastguard Worker
905*912701f9SAndroid Build Coastguard Worker<!ELEMENT region ( currency* ) >
906*912701f9SAndroid Build Coastguard Worker<!ATTLIST region iso3166 NMTOKEN #REQUIRED >
907*912701f9SAndroid Build Coastguard Worker
908*912701f9SAndroid Build Coastguard Worker<!ELEMENT currency ( alternate* ) >
909*912701f9SAndroid Build Coastguard Worker<!ATTLIST currency iso4217 NMTOKEN #REQUIRED >
910*912701f9SAndroid Build Coastguard Worker<!ATTLIST currency from NMTOKEN #IMPLIED >
911*912701f9SAndroid Build Coastguard Worker<!ATTLIST currency to NMTOKEN #IMPLIED >
912*912701f9SAndroid Build Coastguard Worker<!ATTLIST currency tz CDATA #IMPLIED >
913*912701f9SAndroid Build Coastguard Worker<!ATTLIST currency to-tz CDATA #IMPLIED >
914*912701f9SAndroid Build Coastguard Worker<!ATTLIST currency tender ( true | false ) #IMPLIED >
915*912701f9SAndroid Build Coastguard Worker```
916*912701f9SAndroid Build Coastguard Worker
917*912701f9SAndroid Build Coastguard WorkerEach `currencyData` element contains one `fractions` element followed by one or more `region` elements. Here is an example for illustration.
918*912701f9SAndroid Build Coastguard Worker
919*912701f9SAndroid Build Coastguard Worker```xml
920*912701f9SAndroid Build Coastguard Worker<supplementalData>
921*912701f9SAndroid Build Coastguard Worker    <currencyData>
922*912701f9SAndroid Build Coastguard Worker        <fractions>
923*912701f9SAndroid Build Coastguard Worker924*912701f9SAndroid Build Coastguard Worker        <info iso4217="CHF" digits="2" rounding="5"/>
925*912701f9SAndroid Build Coastguard Worker926*912701f9SAndroid Build Coastguard Worker        <info iso4217="ITL" digits="0"/>
927*912701f9SAndroid Build Coastguard Worker928*912701f9SAndroid Build Coastguard Worker        </fractions>
929*912701f9SAndroid Build Coastguard Worker930*912701f9SAndroid Build Coastguard Worker        <region iso3166="IT">
931*912701f9SAndroid Build Coastguard Worker            <currency iso4217="EUR" from="1999-01-01"/>
932*912701f9SAndroid Build Coastguard Worker            <currency iso4217="ITL" from="1862-8-24" to="2002-02-28"/>
933*912701f9SAndroid Build Coastguard Worker        </region>
934*912701f9SAndroid Build Coastguard Worker935*912701f9SAndroid Build Coastguard Worker        <region iso3166="CS">
936*912701f9SAndroid Build Coastguard Worker            <currency iso4217="EUR" from="2003-02-04"/>
937*912701f9SAndroid Build Coastguard Worker            <currency iso4217="CSD" from="2002-05-15"/>
938*912701f9SAndroid Build Coastguard Worker            <currency iso4217="YUM" from="1994-01-24" to="2002-05-15"/>
939*912701f9SAndroid Build Coastguard Worker        </region>
940*912701f9SAndroid Build Coastguard Worker941*912701f9SAndroid Build Coastguard Worker    </currencyData>
942*912701f9SAndroid Build Coastguard Worker943*912701f9SAndroid Build Coastguard Worker</supplementalData>
944*912701f9SAndroid Build Coastguard Worker```
945*912701f9SAndroid Build Coastguard Worker
946*912701f9SAndroid Build Coastguard WorkerThe `fractions` element contains any number of `info` elements, with the following attributes:
947*912701f9SAndroid Build Coastguard Worker
948*912701f9SAndroid Build Coastguard Worker* **iso4217:** the ISO 4217 code for the currency in question. If a particular currency does not occur in the fractions list, then it is given the defaults listed for the next two attributes.
949*912701f9SAndroid Build Coastguard Worker* **digits:** the minimum and maximum number of decimal digits normally formatted. The default is 2. For example, in the en_US locale with the default value of 2 digits, the value 1 USD would format as "$1.00", and the value 1.123 USD would format as → "$1.12".
950*912701f9SAndroid Build Coastguard Worker* **rounding:** the rounding increment, in units of 10<sup>-digits</sup>. The default is 0, which means no rounding is to be done. Therefore, rounding=0 and rounding=1 have identical behavior. Thus with fraction digits of 2 and rounding increment of 5, numeric values are rounded to the nearest 0.05 units in formatting. With fraction digits of 0 and rounding increment of 50, numeric values are rounded to the nearest 50.
951*912701f9SAndroid Build Coastguard Worker* **cashDigits:** the number of decimal digits to be used when formatting quantities used in cash transactions (as opposed to a quantity that would appear in a more formal setting, such as on a bank statement). If absent, the value of "digits" should be used as a default.
952*912701f9SAndroid Build Coastguard Worker* **cashRounding:** the cash rounding increment, in units of 10-cashDigits. The default is 0, which means no rounding is to be done; and as with rounding, this has the same effect as cashRounding="1". This is the rounding increment to be used when formatting quantities used in cash transactions (as opposed to a quantity that would appear in a more formal setting, such as on a bank statement). If absent, the value of "rounding" should be used as a default.
953*912701f9SAndroid Build Coastguard Worker
954*912701f9SAndroid Build Coastguard WorkerFor example, the following line
955*912701f9SAndroid Build Coastguard Worker
956*912701f9SAndroid Build Coastguard Worker```xml
957*912701f9SAndroid Build Coastguard Worker<info iso4217="CZK" digits="2" rounding="0"/>
958*912701f9SAndroid Build Coastguard Worker```
959*912701f9SAndroid Build Coastguard Worker
960*912701f9SAndroid Build Coastguard Workershould cause the value 2.006 to be displayed as “2.01”, not “2.00”.
961*912701f9SAndroid Build Coastguard Worker
962*912701f9SAndroid Build Coastguard WorkerEach `region` element contains one attribute:
963*912701f9SAndroid Build Coastguard Worker
964*912701f9SAndroid Build Coastguard Worker* **iso3166:** the ISO 3166 code for the region in question. The special value _XXX_ can be used to indicate that the region has no valid currency or that the circumstances are unknown (usually used in conjunction with _before_, as described below).
965*912701f9SAndroid Build Coastguard Worker
966*912701f9SAndroid Build Coastguard WorkerAnd can have any number of `currency` elements, with the `ordered` subelements.
967*912701f9SAndroid Build Coastguard Worker
968*912701f9SAndroid Build Coastguard Worker```xml
969*912701f9SAndroid Build Coastguard Worker<region iso3166="HR"> <!-- Croatia -->
970*912701f9SAndroid Build Coastguard Worker    <currency iso4217="EUR" from="2023-01-01" tz="Europe/Zagreb"/>
971*912701f9SAndroid Build Coastguard Worker    <currency iso4217="HRK" from="1994-05-30" to="2023-01-14" to-tz="Europe/Zagreb"/>
972*912701f9SAndroid Build Coastguard Worker    <currency iso4217="HRD" from="1991-12-23" to="1995-01-01"/>
973*912701f9SAndroid Build Coastguard Worker    <currency iso4217="YUN" from="1990-01-01" to="1991-12-23"/>
974*912701f9SAndroid Build Coastguard Worker    <currency iso4217="YUD" from="1966-01-01" to="1990-01-01"/>
975*912701f9SAndroid Build Coastguard Worker</region>
976*912701f9SAndroid Build Coastguard Worker```
977*912701f9SAndroid Build Coastguard Worker
978*912701f9SAndroid Build Coastguard Worker* **iso4217:** the ISO 4217 code for the currency in question. Note that some additional codes that were in widespread usage are included, others such as GHP are not included because they were never used.
979*912701f9SAndroid Build Coastguard Worker* **from:** the currency was valid from the datetime indicated by the value. See the main document _[Dates and Date Ranges](tr35.md#Date_Ranges)_.
980*912701f9SAndroid Build Coastguard Worker* **to:** the currency was valid up to the datetime indicated by the value. See the main document _[Dates and Date Ranges](tr35.md#Date_Ranges)_.
981*912701f9SAndroid Build Coastguard Worker* **tz:** the timezone associated with the `from` transition datetime. If no `to-tz` attribute is specified, it also applies to the `to` transition datetime.
982*912701f9SAndroid Build Coastguard Worker    * Timezones for the `tz` and `to-tz` attribute are specified using the CLDR canonical “long” time zone ID as described under **Stability of Time Zone Identifiers** in [Time Zone Identifiers](tr35.md#Time_Zone_Identifiers).
983*912701f9SAndroid Build Coastguard Worker* **to-tz:** the timezone associated with the `to` transition datetime. This timezone applies to the `to` value, and need only be specified if it is different from any timezone specified by a `tz` attribute.
984*912701f9SAndroid Build Coastguard Worker* **tender:** indicates whether or not the ISO currency code represents a currency that was or is legal tender in some country. The default is "true". Certain ISO codes represent things like financial instruments or precious metals, and do not represent normally interchanged currencies.
985*912701f9SAndroid Build Coastguard Worker
986*912701f9SAndroid Build Coastguard Worker> **Note on converting transition datetimes for implementation use:** The fact that CLDR stores the timezone separately from the transition datetime is for ease of CLDR maintenance. Implementations that use CLDR data may want to convert the combination into something like a single UTC timestamp for internal use.
987*912701f9SAndroid Build Coastguard Worker
988*912701f9SAndroid Build Coastguard WorkerThat is, each `currency` element will list an interval in which it was valid. The _ordering_ of the elements in the list tells us which was the primary currency during any period in time. Here is an example of such an overlap:
989*912701f9SAndroid Build Coastguard Worker
990*912701f9SAndroid Build Coastguard Worker```xml
991*912701f9SAndroid Build Coastguard Worker<currency iso4217="CSD" to="2002-05-15"/>
992*912701f9SAndroid Build Coastguard Worker<currency iso4217="YUD" from="1994-01-24" to="2002-05-15"/>
993*912701f9SAndroid Build Coastguard Worker<currency iso4217="YUN" from="1994-01-01" to="1994-07-22"/>
994*912701f9SAndroid Build Coastguard Worker```
995*912701f9SAndroid Build Coastguard Worker
996*912701f9SAndroid Build Coastguard WorkerThe `from` element is limited by the fact that ISO 4217 does not go very far back in time, so there may be no ISO code for the previous currency.
997*912701f9SAndroid Build Coastguard Worker
998*912701f9SAndroid Build Coastguard WorkerCurrencies change relatively frequently. There are different types of changes:
999*912701f9SAndroid Build Coastguard Worker
1000*912701f9SAndroid Build Coastguard Worker1. YU=>CS (name change)
1001*912701f9SAndroid Build Coastguard Worker2. CS=>RS+ME (split, different names)
1002*912701f9SAndroid Build Coastguard Worker3. SD=>SD+SS (split, same name for one // South Sudan splits from Sudan)
1003*912701f9SAndroid Build Coastguard Worker4. DE+DD=>DE (Union, reuses one name // East Germany unifies with Germany)
1004*912701f9SAndroid Build Coastguard Worker
1005*912701f9SAndroid Build Coastguard WorkerThe [UN Information](https://unstats.un.org/unsd/methodology/m49/) is used to determine dates due to country changes.
1006*912701f9SAndroid Build Coastguard Worker
1007*912701f9SAndroid Build Coastguard WorkerWhen a code is no longer in use, it is terminated (see #1, #2, #4, #5)
1008*912701f9SAndroid Build Coastguard Worker
1009*912701f9SAndroid Build Coastguard Worker> Example:
1010*912701f9SAndroid Build Coastguard Worker>
1011*912701f9SAndroid Build Coastguard Worker> * ```<currency iso4217="EUR" from="2003-02-04" to="2006-06-03"/>```
1012*912701f9SAndroid Build Coastguard Worker
1013*912701f9SAndroid Build Coastguard WorkerWhen codes split, each of the new codes inherits (see #2, #3) the previous data. However, some modifications can be made if it is clear that currencies were only in use in one of the parts.
1014*912701f9SAndroid Build Coastguard Worker
1015*912701f9SAndroid Build Coastguard WorkerWhen codes merge, the data is copied from the most populous part.
1016*912701f9SAndroid Build Coastguard Worker
1017*912701f9SAndroid Build Coastguard Worker> Example. When CS split into RS and ME:
1018*912701f9SAndroid Build Coastguard Worker>
1019*912701f9SAndroid Build Coastguard Worker> * RS & ME copy the former CS, except that the line for EUR is dropped from RS
1020*912701f9SAndroid Build Coastguard Worker> * CS now terminates on Jun 3, 2006 (following the UN info)
1021*912701f9SAndroid Build Coastguard Worker
1022*912701f9SAndroid Build Coastguard Worker## <a name="Language_Plural_Rules" href="#Language_Plural_Rules">Language Plural Rules</a>
1023*912701f9SAndroid Build Coastguard Worker
1024*912701f9SAndroid Build Coastguard Worker```xml
1025*912701f9SAndroid Build Coastguard Worker<!ELEMENT plurals (pluralRules*, pluralRanges*) >
1026*912701f9SAndroid Build Coastguard Worker<!ATTLIST plurals type ( ordinal | cardinal ) #IMPLIED > <!-- default is cardinal -->
1027*912701f9SAndroid Build Coastguard Worker
1028*912701f9SAndroid Build Coastguard Worker<!ELEMENT pluralRules (pluralRule*) >
1029*912701f9SAndroid Build Coastguard Worker<!ATTLIST pluralRules locales NMTOKENS #REQUIRED >
1030*912701f9SAndroid Build Coastguard Worker
1031*912701f9SAndroid Build Coastguard Worker<!ELEMENT pluralRule ( #PCDATA ) >
1032*912701f9SAndroid Build Coastguard Worker<!ATTLIST pluralRule count (zero | one | two | few | many | other) #REQUIRED >
1033*912701f9SAndroid Build Coastguard Worker```
1034*912701f9SAndroid Build Coastguard Worker
1035*912701f9SAndroid Build Coastguard WorkerThe plural categories are used to format messages with numeric placeholders, expressed as decimal numbers. The fundamental rule for determining plural categories is the existence of minimal pairs: whenever two different numbers may require different versions of the same message, then the numbers have different plural categories.
1036*912701f9SAndroid Build Coastguard Worker
1037*912701f9SAndroid Build Coastguard WorkerThis happens even if nouns are invariant; even if all English nouns were invariant (like “sheep”), English would still require 2 plural categories because of subject-verb agreement, and pronoun agreement. For example:
1038*912701f9SAndroid Build Coastguard Worker
1039*912701f9SAndroid Build Coastguard Worker1. 1 sheep **is** here. Do you want to buy **it**?
1040*912701f9SAndroid Build Coastguard Worker2. 2 sheep **are** here. Do you want to buy **them**?
1041*912701f9SAndroid Build Coastguard Worker
1042*912701f9SAndroid Build Coastguard WorkerFor more information, see [Determining-Plural-Categories](https://cldr.unicode.org/index/cldr-spec/plural-rules#h.44ozdx564iez).
1043*912701f9SAndroid Build Coastguard Worker
1044*912701f9SAndroid Build Coastguard WorkerEnglish does not have a separate plural category for “zero”, because it does not require a different message for “0”. For example, the same message can be used below, with just the numeric placeholder changing.
1045*912701f9SAndroid Build Coastguard Worker
1046*912701f9SAndroid Build Coastguard Worker1. You have 3 friends online.
1047*912701f9SAndroid Build Coastguard Worker2. You have 0 friends online.
1048*912701f9SAndroid Build Coastguard Worker
1049*912701f9SAndroid Build Coastguard WorkerHowever, across many languages it is commonly more natural to express "0" messages with a negative (“None of your friends are online.”) and "1" messages also with an alternate form “You have a friend online.”. Thus pluralized message APIs should also offer the ability to specify at least the 0 and 1 cases explicitly; developers can use that ability whenever these values might occur in a placeholder.
1050*912701f9SAndroid Build Coastguard Worker
1051*912701f9SAndroid Build Coastguard WorkerThe CLDR plural rules are not expected to cover all cases. For example, strictly speaking, there could be more plural and ordinal forms for English. Formally, we have a different plural form where a change in digits forces a change in the rest of the sentence. There is an edge case in English because of the behavior of "a/an".
1052*912701f9SAndroid Build Coastguard Worker
1053*912701f9SAndroid Build Coastguard WorkerFor example, in changing from 3 to 8:
1054*912701f9SAndroid Build Coastguard Worker
1055*912701f9SAndroid Build Coastguard Worker* "a 3rd of a loaf" should result in "an 8th of a loaf", not "a 8th of a loaf"
1056*912701f9SAndroid Build Coastguard Worker* "a 3 foot stick" should result in "an 8 foot stick", not "a 8 foot stick"
1057*912701f9SAndroid Build Coastguard Worker
1058*912701f9SAndroid Build Coastguard WorkerSo numbers of the following forms could have a special plural category and special ordinal category: 8(X), 11(X), 18(X), 8x(X), where x is 0..9 and the optional X is 00, 000, 00000, and so on.
1059*912701f9SAndroid Build Coastguard Worker
1060*912701f9SAndroid Build Coastguard WorkerOn the other hand, the above constructions are relatively rare in messages constructed using numeric placeholders, so the disruption for implementations currently using CLDR plural categories wouldn't be worth the small gain.
1061*912701f9SAndroid Build Coastguard Worker
1062*912701f9SAndroid Build Coastguard WorkerThis section defines the types of plural forms that exist in a language—namely, the cardinal and ordinal plural forms. Cardinal plural forms express units such as time, currency or distance, used in conjunction with a number expressed in decimal digits (i.e. "2", not "two", and not an indefinite number such as "some" or "many"). Ordinal plural forms denote the order of items in a set and are always integers. For example, English has two forms for cardinals:
1063*912701f9SAndroid Build Coastguard Worker
1064*912701f9SAndroid Build Coastguard Worker* form "one": 1 day
1065*912701f9SAndroid Build Coastguard Worker* form "other": 0 days, 2 days, 10 days, 0.3 days
1066*912701f9SAndroid Build Coastguard Worker
1067*912701f9SAndroid Build Coastguard Workerand four forms for ordinals:
1068*912701f9SAndroid Build Coastguard Worker
1069*912701f9SAndroid Build Coastguard Worker* form "one": 1st floor, 21st floor, 101st floor
1070*912701f9SAndroid Build Coastguard Worker* form "two": 2nd floor, 22nd floor, 102nd floor
1071*912701f9SAndroid Build Coastguard Worker* form "few": 3rd floor, 23rd floor, 103rd floor
1072*912701f9SAndroid Build Coastguard Worker* form "other": 4th floor, 11th floor, 96th floor
1073*912701f9SAndroid Build Coastguard Worker
1074*912701f9SAndroid Build Coastguard WorkerOther languages may have additional forms or only one form for each type of plural. CLDR provides the following tags for designating the various plural forms of a language; for a given language, only the tags necessary for that language are defined, along with the specific numeric ranges covered by each tag (for example, the plural form "few" may be used for the numeric range 2–4 in one language and 3–9 in another):
1075*912701f9SAndroid Build Coastguard Worker
1076*912701f9SAndroid Build Coastguard Worker* zero (see also plural case “0”, described in [Explicit 0 and 1 rules](#Explicit_0_1_rules))
1077*912701f9SAndroid Build Coastguard Worker* one (see also plural case “1”, described in [Explicit 0 and 1 rules](#Explicit_0_1_rules))
1078*912701f9SAndroid Build Coastguard Worker* two
1079*912701f9SAndroid Build Coastguard Worker* few
1080*912701f9SAndroid Build Coastguard Worker* many
1081*912701f9SAndroid Build Coastguard Worker
1082*912701f9SAndroid Build Coastguard WorkerIn addition, an "other" tag is always implicitly defined to cover the forms not explicitly designated by the tags defined for a language. This "other" tag is also used for languages that only have a single form (in which case no plural-form tags are explicitly defined for the language). For a more complex example, consider the cardinal rules for Russian and certain other languages:
1083*912701f9SAndroid Build Coastguard Worker
1084*912701f9SAndroid Build Coastguard Worker```xml
1085*912701f9SAndroid Build Coastguard Worker<pluralRules locales="hr ru sr uk">
1086*912701f9SAndroid Build Coastguard Worker    <pluralRules count="one">n mod 10 is 1 and n mod 100 is not 11</pluralRule>
1087*912701f9SAndroid Build Coastguard Worker    <pluralRules count="few">n mod 10 in 2..4 and n mod 100 not in 12..14</pluralRule>
1088*912701f9SAndroid Build Coastguard Worker</pluralRules>
1089*912701f9SAndroid Build Coastguard Worker```
1090*912701f9SAndroid Build Coastguard Worker
1091*912701f9SAndroid Build Coastguard WorkerThese rules specify that Russian has a "one" form (for 1, 21, 31, 41, 51, …), a "few" form (for 2–4, 22–24, 32–34, …), and implicitly an "other" form (for everything else: 0, 5–20, 25–30, 35–40, …, decimals). Russian does not need additional separate forms for zero, two, or many, so these are not defined.
1092*912701f9SAndroid Build Coastguard Worker
1093*912701f9SAndroid Build Coastguard WorkerA source number represents the visual appearance of the digits of the result. In text, it can be represented by the EBNF for sampleValue. Note that the same double number can be represented by multiple source numbers. For example, "1.0" and "1.00" are different source numbers, but there is only one double number that they correspond to: 1.0d == 1.00d. As another example, 1e3d == 1000d, but the source numbers "1e3" and "1000" are different, and can have different plural categories. So the input to the plural rules carries more information than a computer double. The plural category for negative numbers is calculated according to the absolute value of the source number, and leading integer digits don't have any effect on the plural category calculation. (This may change in the future, if we find languages that have different behavior.)
1094*912701f9SAndroid Build Coastguard Worker
1095*912701f9SAndroid Build Coastguard WorkerPlural categories may also differ according to the visible decimals. For example, here are some of the behaviors exhibited by different languages:
1096*912701f9SAndroid Build Coastguard Worker
1097*912701f9SAndroid Build Coastguard Worker| Behavior | Description | Example |
1098*912701f9SAndroid Build Coastguard Worker| --- | --- | --- |
1099*912701f9SAndroid Build Coastguard Worker| Base | The fractions are ignored; the category is the same as the category of the integer. | 1.13 has the same plural category as 1. |
1100*912701f9SAndroid Build Coastguard Worker| Separate | All fractions by value are in one category (typically ‘other’ = ‘plural’). | 1.01 gets the same class as 9; <br/> 1.00 gets the same category as 1. |
1101*912701f9SAndroid Build Coastguard Worker| Visible | All visible fractions are in one category (typically ‘other’ = ‘plural’). | 1.00, 1.01, 3.5 all get the same category. |
1102*912701f9SAndroid Build Coastguard Worker| Digits | The visible fraction determines the category. | 1.13 gets the same class as 13. |
1103*912701f9SAndroid Build Coastguard Worker
1104*912701f9SAndroid Build Coastguard WorkerThere are also variants of the above: for example, short fractions may have the Digits behavior, but longer fractions may just look at the final digit of the fraction.
1105*912701f9SAndroid Build Coastguard Worker
1106*912701f9SAndroid Build Coastguard WorkerCurrently there are no locale keywords that affect plural rule selection; they are selected using the base locale ID, ignoring any -u- extension keywords.
1107*912701f9SAndroid Build Coastguard Worker
1108*912701f9SAndroid Build Coastguard Worker#### <a name="Explicit_0_1_rules" href="#Explicit_0_1_rules">Explicit 0 and 1 rules</a>
1109*912701f9SAndroid Build Coastguard Worker
1110*912701f9SAndroid Build Coastguard WorkerSome types of CLDR data (such as [unitPatterns](tr35-general.md#Unit_Elements) and [currency displayNames](#Currencies)) allow specification of plural rules for explicit cases “0” and “1”, in addition to the language-specific plural cases specified above: “zero”, “one”, “two” ... “other”. For the language-specific plural rules:
1111*912701f9SAndroid Build Coastguard Worker
1112*912701f9SAndroid Build Coastguard Worker* The rules depend on language; for a given language, only a subset of the cases may be defined. For example, English only defines “one” and “other”, cases like “two” and “few” cannot be used in plurals for English CLDR items.
1113*912701f9SAndroid Build Coastguard Worker* Each plural case may cover multiple numeric values, and may depend on the formatting of those values. For example, in French the “one” case covers 0.0 through 1.99.
1114*912701f9SAndroid Build Coastguard Worker* The “one” case, if defined, includes at least some formatted forms of the numeric value 1; the “zero” case, if defined, includes at least some formatted forms of the numeric value 0.
1115*912701f9SAndroid Build Coastguard Worker
1116*912701f9SAndroid Build Coastguard WorkerBy contrast, for the explicit cases “0” and “1”:
1117*912701f9SAndroid Build Coastguard Worker
1118*912701f9SAndroid Build Coastguard Worker* The explicit “0” and “1” cases are not defined by language-specific rules, and are available in any language for the CLDR data items that accept them.
1119*912701f9SAndroid Build Coastguard Worker* The explicit “0” and “1” cases apply to the exact numeric values 0 and 1 respectively. These cases are typically used for plurals of items that do not have fractional value, like books or files.
1120*912701f9SAndroid Build Coastguard Worker* The explicit “0” and “1” cases have precedence over the “zero” and “one” cases. For example, if for a particular element CLDR data includes values for both the “1” and “one” cases, then the “1” value is used for numeric values of exactly 1, while the “one” value is used for any other formatted numeric values matching the “one” plural rule for the language.
1121*912701f9SAndroid Build Coastguard Worker
1122*912701f9SAndroid Build Coastguard WorkerUsage example: In English (which only defines language-specific rules for “one” and “other”) this can be used to have special behavior for 0:
1123*912701f9SAndroid Build Coastguard Worker
1124*912701f9SAndroid Build Coastguard Worker* count=“0”: no books
1125*912701f9SAndroid Build Coastguard Worker* count=“one”: {0} book, e.g. “1 book”
1126*912701f9SAndroid Build Coastguard Worker* count=“other”: {0} books, e.g. “3 books”
1127*912701f9SAndroid Build Coastguard Worker
1128*912701f9SAndroid Build Coastguard Worker### <a name="Plural_rules_syntax" href="#Plural_rules_syntax">Plural rules syntax</a>
1129*912701f9SAndroid Build Coastguard Worker
1130*912701f9SAndroid Build Coastguard WorkerThe xml value for each pluralRule is a _condition_ with a boolean result.
1131*912701f9SAndroid Build Coastguard WorkerThat value specifies whether that rule (i.e. that plural form) applies to a given _source number N_ in sampleValue syntax, where _N_ can be expressed as a decimal fraction or with compact decimal formatting.
1132*912701f9SAndroid Build Coastguard WorkerThe compact decimal formatting is denoted by a special notation in the syntax, e.g., “1.2c6” for “1.2M”.
1133*912701f9SAndroid Build Coastguard WorkerClients of CLDR may express all the rules for a locale using the following syntax:
1134*912701f9SAndroid Build Coastguard Worker
1135*912701f9SAndroid Build Coastguard Worker```
1136*912701f9SAndroid Build Coastguard Workerrules         = rule (';' rule)*
1137*912701f9SAndroid Build Coastguard Workerrule          = keyword ':' condition samples
1138*912701f9SAndroid Build Coastguard Worker              | 'other' ':' samples
1139*912701f9SAndroid Build Coastguard Workerkeyword       = [a-z]+
1140*912701f9SAndroid Build Coastguard Workerkeyword       = [a-z]+
1141*912701f9SAndroid Build Coastguard Worker```
1142*912701f9SAndroid Build Coastguard Worker
1143*912701f9SAndroid Build Coastguard WorkerIn CLDR, the keyword is the attribute value of 'count'. Those values in CLDR are currently limited to just what is in the DTD, but clients may support other values.
1144*912701f9SAndroid Build Coastguard Worker
1145*912701f9SAndroid Build Coastguard WorkerThe conditions themselves have the following syntax.
1146*912701f9SAndroid Build Coastguard Worker
1147*912701f9SAndroid Build Coastguard Worker```
1148*912701f9SAndroid Build Coastguard Workercondition       = and_condition ('or' and_condition)*
1149*912701f9SAndroid Build Coastguard Workersamples         = ('@integer' sampleList)?
1150*912701f9SAndroid Build Coastguard Worker                  ('@decimal' sampleList)?
1151*912701f9SAndroid Build Coastguard Workerand_condition   = relation ('and' relation)*
1152*912701f9SAndroid Build Coastguard Workerrelation        = is_relation | in_relation | within_relation
1153*912701f9SAndroid Build Coastguard Workeris_relation     = expr 'is' ('not')? value
1154*912701f9SAndroid Build Coastguard Workerin_relation     = expr (('not')? 'in' | '=' | '!=') range_list
1155*912701f9SAndroid Build Coastguard Workerwithin_relation = expr ('not')? 'within' range_list
1156*912701f9SAndroid Build Coastguard Workerexpr            = operand (('mod' | '%') value)?
1157*912701f9SAndroid Build Coastguard Workeroperand         = 'n' | 'i' | 'f' | 't' | 'v' | 'w' | 'c' | 'e'
1158*912701f9SAndroid Build Coastguard Workerrange_list      = (range | value) (',' range_list)*
1159*912701f9SAndroid Build Coastguard Workerrange           = value'..'value
1160*912701f9SAndroid Build Coastguard Workervalue           = digit+
1161*912701f9SAndroid Build Coastguard WorkersampleList      = sampleRange (',' sampleRange)* (',' ('…'|'...'))?
1162*912701f9SAndroid Build Coastguard WorkersampleRange     = sampleValue ('~' sampleValue)?
1163*912701f9SAndroid Build Coastguard WorkersampleValue     = sign? value ('.' digit+)? ([ce] digitPos digit+)?
1164*912701f9SAndroid Build Coastguard Workersign            = '+' | '-'
1165*912701f9SAndroid Build Coastguard Workerdigit           = [0-9]
1166*912701f9SAndroid Build Coastguard WorkerdigitPos        = [1-9]
1167*912701f9SAndroid Build Coastguard Worker```
1168*912701f9SAndroid Build Coastguard Worker
1169*912701f9SAndroid Build Coastguard Worker* Whitespace (defined as Unicode [Pattern_White_Space](https://util.unicode.org/UnicodeJsps/list-unicodeset.jsp?a=%5Cp%7BPattern_White_Space%7D)) can occur between or around any of the above tokens, with the exception of the tokens in value, digit, and sampleValue.
1170*912701f9SAndroid Build Coastguard Worker* In the syntax, **and** binds more tightly than **or**. So **X or Y and Z** is interpreted as **(X or (Y and Z))**.
1171*912701f9SAndroid Build Coastguard Worker  * For example, e = 0 and i != 0 and i % 1000000 = 0 and *+v = 0+* or e != 0..5 is parsed as if it were (e = 0 and i != 0 and i % 1000000 = 0 and v = 0) or (e != 0..5)
1172*912701f9SAndroid Build Coastguard Worker* Each plural rule must be written to be self-contained, and not depend on the ordering. Thus rules must be mutually exclusive; for a given numeric value, only one rule can apply (i.e., the condition can only be true for one of the pluralRule elements). Each keyword can have at most one condition. The 'other' keyword must have an empty condition: it is only present for samples.
1173*912701f9SAndroid Build Coastguard Worker* The samples should be included, since they are used by client software for samples and determining whether the keyword has finite values or not.
1174*912701f9SAndroid Build Coastguard Worker* The 'other' keyword must have no condition, and all other keywords must have a condition.
1175*912701f9SAndroid Build Coastguard Worker
1176*912701f9SAndroid Build Coastguard Worker#### <a name="Operands" href="#Operands">Operands</a>
1177*912701f9SAndroid Build Coastguard Worker
1178*912701f9SAndroid Build Coastguard WorkerThe operands are numeric values corresponding to features of the *source number N*, and have the following meanings given in the table below.
1179*912701f9SAndroid Build Coastguard WorkerNote that, contrary to source numbers, operands are treated numerically.
1180*912701f9SAndroid Build Coastguard WorkerAlthough some of them are used to describe insignificant 0s in the source number, any insignificant 0s in the operands themselves are ignored, e.g., f=03 is equivalent to f=3.
1181*912701f9SAndroid Build Coastguard Worker
1182*912701f9SAndroid Build Coastguard Worker###### Table: <a name="Plural_Operand_Meanings" href="#Plural_Operand_Meanings">Plural Operand Meanings</a>
1183*912701f9SAndroid Build Coastguard Worker
1184*912701f9SAndroid Build Coastguard Worker| Symbol | Value |
1185*912701f9SAndroid Build Coastguard Worker| --- | --- |
1186*912701f9SAndroid Build Coastguard Worker| n | the absolute value of N.* |
1187*912701f9SAndroid Build Coastguard Worker| i | the integer digits of N.* |
1188*912701f9SAndroid Build Coastguard Worker| v | the number of visible fraction digits in N, _with_ trailing zeros.* |
1189*912701f9SAndroid Build Coastguard Worker| w | the number of visible fraction digits in N, _without_ trailing zeros.* |
1190*912701f9SAndroid Build Coastguard Worker| f | the visible fraction digits in N, _with_ trailing zeros, expressed as an integer.* |
1191*912701f9SAndroid Build Coastguard Worker| t | the visible fraction digits in N, _without_ trailing zeros, expressed as an integer.* |
1192*912701f9SAndroid Build Coastguard Worker| c | compact decimal exponent value: exponent of the power of 10 used in compact decimal formatting. |
1193*912701f9SAndroid Build Coastguard Worker| e | a deprecated synonym for ‘c’. Note: it may be redefined in the future. |
1194*912701f9SAndroid Build Coastguard Worker
1195*912701f9SAndroid Build Coastguard Worker\* If there is a compact decimal exponent value (‘c’), then the n, i, f, t, v, and w values are computed _after_ shifting the decimal point in the original by the ‘c’ value.
1196*912701f9SAndroid Build Coastguard WorkerSo for 1.2c3, the n, i, f, t, v, and w values are the same as those of 1200:  i=1200 and f=0.
1197*912701f9SAndroid Build Coastguard WorkerSimilarly, 1.2005c3 has i=1200 and f=5 (corresponding to 1200.5).
1198*912701f9SAndroid Build Coastguard Worker
1199*912701f9SAndroid Build Coastguard Worker###### Table: <a name="Plural_Operand_Examples" href="#Plural_Operand_Examples">Plural Operand Examples</a>
1200*912701f9SAndroid Build Coastguard Worker
1201*912701f9SAndroid Build Coastguard Worker| source | n | i | v | w | f | t | e |
1202*912701f9SAndroid Build Coastguard Worker| ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
1203*912701f9SAndroid Build Coastguard Worker| 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 |
1204*912701f9SAndroid Build Coastguard Worker| 1.0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
1205*912701f9SAndroid Build Coastguard Worker| 1.00 | 1 | 1 | 2 | 0 | 0 | 0 | 0 |
1206*912701f9SAndroid Build Coastguard Worker| 1.3 | 1.3 | 1 | 1 | 1 | 3 | 3 | 0 |
1207*912701f9SAndroid Build Coastguard Worker| 1.30 | 1.3 | 1 | 2 | 1 | 30 | 3 | 0 |
1208*912701f9SAndroid Build Coastguard Worker| 1.03 | 1.03 | 1 | 2 | 2 | 3 | 3 | 0 |
1209*912701f9SAndroid Build Coastguard Worker| 1.230 | 1.23 | 1 | 3 | 2 | 230 | 23 | 0 |
1210*912701f9SAndroid Build Coastguard Worker| 1200000 | 1200000 | 1200000 | 0 | 0 | 0 | 0 | 0 |
1211*912701f9SAndroid Build Coastguard Worker| 1.2c6 | 1200000 | 1200000 | 0 | 0 | 0 | 0 | 6 |
1212*912701f9SAndroid Build Coastguard Worker| 123c6 | 123000000 | 123000000 | 0 | 0 | 0 | 0 | 6 |
1213*912701f9SAndroid Build Coastguard Worker| 123c5 | 12300000 | 12300000 | 0 | 0 | 0 | 0 | 5 |
1214*912701f9SAndroid Build Coastguard Worker| 1200.50 | 1200.5 | 1200 | 2 | 1 | 50 | 5 | 0 |
1215*912701f9SAndroid Build Coastguard Worker| 1.20050c3 | 1200.5 | 1200 | 2 | 1 | 50 | 5 | 3 |
1216*912701f9SAndroid Build Coastguard Worker
1217*912701f9SAndroid Build Coastguard Worker
1218*912701f9SAndroid Build Coastguard Worker#### <a name="Relations" href="#Relations">Relations</a>
1219*912701f9SAndroid Build Coastguard Worker
1220*912701f9SAndroid Build Coastguard WorkerThe positive relations are of the format **x = y** and **x = y mod z**. The **y** value can be a comma-separated list, such as **n = 3, 5, 7..15**, and is treated as if each relation were expanded into an OR statement. The range value **a..b** is equivalent to listing all the ***integers*** between **a** and **b**, inclusive. When **!=** is used, it means the entire relation is negated.
1221*912701f9SAndroid Build Coastguard Worker
1222*912701f9SAndroid Build Coastguard Worker###### Table: <a name="Relations_Examples" href="#Relations_Examples">Relations Examples</a>
1223*912701f9SAndroid Build Coastguard Worker
1224*912701f9SAndroid Build Coastguard Worker| Expression | Meaning |
1225*912701f9SAndroid Build Coastguard Worker| --- | --- |
1226*912701f9SAndroid Build Coastguard Worker| x = 2..4, 15 | x = 2 OR x = 3 OR x = 4 OR x = 15 |
1227*912701f9SAndroid Build Coastguard Worker| x != 2..4, 15 | NOT (x = 2 OR x = 3 OR x = 4 OR x = 15) |
1228*912701f9SAndroid Build Coastguard Worker
1229*912701f9SAndroid Build Coastguard Worker| Expression | Value |
1230*912701f9SAndroid Build Coastguard Worker| --- | --- |
1231*912701f9SAndroid Build Coastguard Worker| 3.5 = 2..4, 15 | false |
1232*912701f9SAndroid Build Coastguard Worker| 3.5 != 2..4, 15 | true |
1233*912701f9SAndroid Build Coastguard Worker| 3 = 2..4, 15 | true |
1234*912701f9SAndroid Build Coastguard Worker| 3 != 2..4, 15 | false |
1235*912701f9SAndroid Build Coastguard Worker
1236*912701f9SAndroid Build Coastguard Worker> The old keywords 'mod', 'in', 'is', and 'within' are present only for backwards compatibility. The preferred form is to use '%' for modulo, and '=' or '!=' for the relations, with the operand 'i' instead of within. (The difference between **in** and **within** is that **in** only includes integers in the specified range, while **within** includes all values.)
1237*912701f9SAndroid Build Coastguard Worker
1238*912701f9SAndroid Build Coastguard WorkerThe modulus (% or **mod**) is a remainder operation as defined in Java; for example, where **n** = 4.3 the result of **n mod 3** is 1.3.
1239*912701f9SAndroid Build Coastguard Worker
1240*912701f9SAndroid Build Coastguard WorkerThe values of relations are defined according to the operand as follows. Importantly, the results may depend on the visible decimals in the source, including trailing zeros, and the compact decimal exponent.
1241*912701f9SAndroid Build Coastguard Worker
1242*912701f9SAndroid Build Coastguard Worker1. Let the base value BV be computed from absolute value of the original source number according to the operand.
1243*912701f9SAndroid Build Coastguard Worker2. Let R be false when the comparison contains ‘not’.
1244*912701f9SAndroid Build Coastguard Worker3. Let R be !R if the comparison contains ‘within’ and the source number is not an integer.
1245*912701f9SAndroid Build Coastguard Worker4. If there is a module value MV, let BV be BV - floor(BV/MV).
1246*912701f9SAndroid Build Coastguard Worker5. Let CR be the list of comparison ranges, normalized that overlapping ranges are merged. Single values in the rule are represented by a range with identical \<starti, endi> values.
1247*912701f9SAndroid Build Coastguard Worker6. Iterate through CR:
1248*912701f9SAndroid Build Coastguard Worker   * if starti ≤ BV ≤ endi then return R.
1249*912701f9SAndroid Build Coastguard Worker7. Otherwise return !R.
1250*912701f9SAndroid Build Coastguard Worker
1251*912701f9SAndroid Build Coastguard Worker###### Table: <a name="Plural_Rules_Examples" href="#Plural_Rules_Examples">Plural Rules Examples</a>
1252*912701f9SAndroid Build Coastguard Worker
1253*912701f9SAndroid Build Coastguard Worker| Rules | Comments |
1254*912701f9SAndroid Build Coastguard Worker| --- | --- |
1255*912701f9SAndroid Build Coastguard Worker| one: n = 1 <br/> few: n = 2..4 | This defines two rules, for 'one' and 'few'. The condition for 'one' is "n = 1" which means that the number must be equal to 1 for this condition to pass. The condition for 'few' is "n = 2..4" which means that the number must be between 2 and 4 inclusive for this condition to pass. All other numbers are assigned the keyword 'other' by the default rule. |
1256*912701f9SAndroid Build Coastguard Worker| zero: n = 0 or n != 1 and n mod 100 = 1..19 <br/> one: n = 1 | Each rule must not overlap with other rules. Also note that a modulus is applied to n in the last rule, thus its condition holds for 119, 219, 319, … |
1257*912701f9SAndroid Build Coastguard Worker| one: n = 1 <br/> few: n mod 10 = 2..4 and n mod 100 != 12..14 | This illustrates conjunction and negation. The condition for 'few' has two parts, both of which must be met: "n mod 10 = 2..4" and "n mod 100 != 12..14". The first part applies a modulus to n before the test as in the previous example. The second part applies a different modulus and also uses negation, thus it matches all numbers _not_ in 12, 13, 14, 112, 113, 114, 212, 213, 214, … |
1258*912701f9SAndroid Build Coastguard Worker
1259*912701f9SAndroid Build Coastguard Worker#### <a name="Samples" href="#Samples">Samples</a>
1260*912701f9SAndroid Build Coastguard Worker
1261*912701f9SAndroid Build Coastguard WorkerSamples are provided if sample indicator (@integer or @decimal) is present on any rule. (CLDR always provides samples.)
1262*912701f9SAndroid Build Coastguard Worker
1263*912701f9SAndroid Build Coastguard WorkerWhere samples are provided, the absence of one of the sample indicators indicates that no numeric values can satisfy that rule. For example, the rule "i = 1 and v = 0" can only have integer samples, so @decimal must not occur. The @integer samples have no visible fraction digits, while @decimal samples have visible fraction digits; both can have compact decimal exponent values (if the 'e' operand occurs).
1264*912701f9SAndroid Build Coastguard Worker
1265*912701f9SAndroid Build Coastguard WorkerThe sampleRanges have a special notation: **start**~**end**. The **start** and **end** values must have the same number of decimal digits, and the same compact decimal exponent values (or neither have compact decimal exponent values). The range encompasses all and only those values **v** where **start ≤ v ≤ end**, and where **v** has the same number of decimal places as **start** and **end**, and the same compact decimal exponent values.
1266*912701f9SAndroid Build Coastguard Worker
1267*912701f9SAndroid Build Coastguard WorkerSamples must indicate whether they are infinite or not. The '…' marker must be present if and only if infinitely many values (integer or decimal) can satisfy the rule. If a set is not infinite, it must list all the possible values.
1268*912701f9SAndroid Build Coastguard Worker
1269*912701f9SAndroid Build Coastguard Worker###### Table: <a name="Plural_Samples_Examples" href="#Plural_Samples_Examples">Plural Samples Examples</a>
1270*912701f9SAndroid Build Coastguard Worker
1271*912701f9SAndroid Build Coastguard Worker| Rules | Comments |
1272*912701f9SAndroid Build Coastguard Worker| --- | --- |
1273*912701f9SAndroid Build Coastguard Worker| @integer 1, 3~5 | 1, 3, 4, 5. |
1274*912701f9SAndroid Build Coastguard Worker| @integer 3\~5, 103\~105, … | Infinite set: 3, 4, 5, 103, 104, 105, … |
1275*912701f9SAndroid Build Coastguard Worker| @decimal 1.3\~1.5, 1.03\~1.05, … | Infinite set: 1.3, 1.4, 1.5, 1.03, 1.04, 1.05, … |
1276*912701f9SAndroid Build Coastguard Worker
1277*912701f9SAndroid Build Coastguard WorkerIn determining whether a set of samples is infinite, leading zero integer digits and trailing zero decimals are not significant. Thus "i = 1000 and f = 0" is satisfied by 01000, 1000, 1000.0, 1000.00, 1000.000, 01c3 etc. but is still considered finite.
1278*912701f9SAndroid Build Coastguard Worker
1279*912701f9SAndroid Build Coastguard Worker#### <a name="Using_cardinals" href="#Using_cardinals">Using Cardinals</a>
1280*912701f9SAndroid Build Coastguard Worker
1281*912701f9SAndroid Build Coastguard WorkerElements such as `<currencyFormats>`, `<currency>` and `<unit>` provide selection among subelements designating various localized cardinal plural forms by tagging each of the relevant subelements with a different count value, or with no count value in some cases. Note that the plural forms for a specific currencyFormat, unit type, or currency type may not use all of the different plural-form tags defined for the language. To format a currency or unit type for a particular numeric value, determine the count value according to the plural rules for the language, then select the appropriate display form for the currency format, currency type or unit type using the rules in those sections:
1282*912701f9SAndroid Build Coastguard Worker
1283*912701f9SAndroid Build Coastguard Worker* 2.3 [Number Symbols](#Number_Symbols) (for `currencyFormat`s elements)
1284*912701f9SAndroid Build Coastguard Worker* [Currencies](#Currencies) (for `currency` elements)
1285*912701f9SAndroid Build Coastguard Worker* The main document [Unit Elements](tr35.md#Unit_Elements)
1286*912701f9SAndroid Build Coastguard Worker
1287*912701f9SAndroid Build Coastguard Worker### <a name="Plural_Ranges" href="#Plural_Ranges">Plural Ranges</a>
1288*912701f9SAndroid Build Coastguard Worker
1289*912701f9SAndroid Build Coastguard Worker```xml
1290*912701f9SAndroid Build Coastguard Worker<!ELEMENT pluralRanges (pluralRange*) >
1291*912701f9SAndroid Build Coastguard Worker<!ATTLIST pluralRanges locales NMTOKENS #REQUIRED >
1292*912701f9SAndroid Build Coastguard Worker
1293*912701f9SAndroid Build Coastguard Worker<!ELEMENT pluralRange ( #PCDATA ) >
1294*912701f9SAndroid Build Coastguard Worker<!ATTLIST pluralRange start (zero|one|two|few|many|other) #IMPLIED >
1295*912701f9SAndroid Build Coastguard Worker<!ATTLIST pluralRange end (zero|one|two|few|many|other) #IMPLIED >
1296*912701f9SAndroid Build Coastguard Worker<!ATTLIST pluralRange result (zero|one|two|few|many|other) #REQUIRED >
1297*912701f9SAndroid Build Coastguard Worker```
1298*912701f9SAndroid Build Coastguard Worker
1299*912701f9SAndroid Build Coastguard WorkerOften ranges of numbers are presented to users, such as in “Length: 3.2–4.5 centimeters”. This means any length from 3.2 cm to 4.5 cm, inclusive. However, different languages have different conventions for the pluralization given to a range: should it be “0–1 centimeter” or “0–1 centimeters”? This becomes much more complicated for languages that have many different plural forms, such as Russian or Arabic.
1300*912701f9SAndroid Build Coastguard Worker
1301*912701f9SAndroid Build Coastguard WorkerThe `pluralRanges` element provides information allowing an implementation to derive the plural category of a range from the plural categories of the `start` and `end` values. If there is no value for a _<`start`,`end`>_ pair, the default result is `end`. However, where that result has been verified for a given language, it is included in the CLDR data.
1302*912701f9SAndroid Build Coastguard Worker
1303*912701f9SAndroid Build Coastguard WorkerThe data has been gathered presuming that in any usage, the start value is strictly less than the end value, and that no values are negative. Results for any cases that do not meet these criteria are undefined.
1304*912701f9SAndroid Build Coastguard Worker
1305*912701f9SAndroid Build Coastguard WorkerFor the formatting of number ranges, see <a href="#Number_Range_Formatting">Number Range Formatting</a>.
1306*912701f9SAndroid Build Coastguard Worker
1307*912701f9SAndroid Build Coastguard Worker## <a name="Rule-Based_Number_Formatting" href="#Rule-Based_Number_Formatting">Rule-Based Number Formatting</a>
1308*912701f9SAndroid Build Coastguard Worker
1309*912701f9SAndroid Build Coastguard Worker```xml
1310*912701f9SAndroid Build Coastguard Worker<!ELEMENT rbnf ( alias | rulesetGrouping*) >
1311*912701f9SAndroid Build Coastguard Worker
1312*912701f9SAndroid Build Coastguard Worker<!ELEMENT rulesetGrouping ( alias | ruleset*) >
1313*912701f9SAndroid Build Coastguard Worker<!ATTLIST rulesetGrouping type NMTOKEN #REQUIRED>
1314*912701f9SAndroid Build Coastguard Worker
1315*912701f9SAndroid Build Coastguard Worker<!ELEMENT ruleset ( alias | rbnfrule*) >
1316*912701f9SAndroid Build Coastguard Worker<!ATTLIST ruleset type NMTOKEN #REQUIRED>
1317*912701f9SAndroid Build Coastguard Worker<!ATTLIST ruleset access ( public | private ) #IMPLIED >
1318*912701f9SAndroid Build Coastguard Worker
1319*912701f9SAndroid Build Coastguard Worker<!ELEMENT rbnfrule ( #PCDATA ) >
1320*912701f9SAndroid Build Coastguard Worker<!ATTLIST rbnfrule value CDATA #REQUIRED >
1321*912701f9SAndroid Build Coastguard Worker<!ATTLIST rbnfrule radix CDATA #IMPLIED >
1322*912701f9SAndroid Build Coastguard Worker<!ATTLIST rbnfrule decexp CDATA #IMPLIED >
1323*912701f9SAndroid Build Coastguard Worker```
1324*912701f9SAndroid Build Coastguard Worker
1325*912701f9SAndroid Build Coastguard WorkerThe rule-based number format (RBNF) encapsulates a set of rules for mapping binary numbers to and from a readable representation. They are typically used for spelling out numbers, but can also be used for other number systems like roman numerals, Chinese numerals, or for ordinal numbers (1st, 2nd, 3rd, …).
1326*912701f9SAndroid Build Coastguard Worker
1327*912701f9SAndroid Build Coastguard WorkerWhere, however, the CLDR plurals or ordinals can be used, their usage is recommended in preference to the RBNF data. First, the RBNF data is not completely fleshed out over all languages that otherwise have modern coverage. Secondly, the alternate forms are neither complete, nor useful without additional information. For example, for German there is spellout-cardinal-masculine, and spellout-cardinal-feminine. But a complete solution would have all genders (masculine/feminine/neuter), all cases (nominative, accusative, dative, genitive), plus context (with strong or weak determiner or none). Moreover, even for the alternate forms that do exist, CLDR does not supply any data for when to use one vs another (eg, when to use spellout-cardinal-masculine vs spellout-cardinal-feminine). So these data are inappropriate for general purpose software.
1328*912701f9SAndroid Build Coastguard Worker
1329*912701f9SAndroid Build Coastguard WorkerThere are 4 common spellout rules. Some languages may provide more than these 4 types:
1330*912701f9SAndroid Build Coastguard Worker
1331*912701f9SAndroid Build Coastguard Worker* **numbering:** This is the default used when there is no context for the number. For many languages, this may also be used for enumeration of objects, like used when pronouncing "table number one" and "table number two". It can also be used for pronouncing a math equation, like "2 - 3 = -1".
1332*912701f9SAndroid Build Coastguard Worker* **numbering-year:** This is used for cases where years are pronounced or written a certain way. An example in English is the year 1999, which comes out as "nineteen ninety-nine" instead of the numbering value "one thousand nine hundred ninety-nine". The rules for this type have undefined behavior for non-integer numbers, and values less than 1.
1333*912701f9SAndroid Build Coastguard Worker* **cardinal:** This is used when providing the quantity of the number of objects. For many languages, there may not be a default cardinal type. Many languages require the notion of the gender and other grammatical properties so that the number and the objects being referenced are in grammatical agreement. An example of its usage is "one e-mail", "two people" or "three kilometers". Some languages may not have dedicated words for 0 or negative numbers for cardinals. In those cases, the words from the numbering type can be reused.
1334*912701f9SAndroid Build Coastguard Worker* **ordinal:** This is used when providing the order of the number of objects. For many languages, there may not be a default ordinal type. Many languages also require the notion of the gender for ordinal so that the ordinal number and the objects being referenced are in grammatical agreement. An example of its usage is "first place", "second e-mail" or "third house on the right". The rules for this type have undefined behavior for non-integer numbers, and values less than 1.
1335*912701f9SAndroid Build Coastguard Worker
1336*912701f9SAndroid Build Coastguard WorkerIn addition to the spellout rules, there are also numbering system rules. Even though they may be derived from a specific culture, they are typically not translated and the rules are in **root**. An example of these rules are the Roman numerals where the value 8 comes out as VIII.
1337*912701f9SAndroid Build Coastguard Worker
1338*912701f9SAndroid Build Coastguard WorkerWith regards to the number range supported for all these number types, the largest possible number range tries to be supported, but some languages may not have words for large numbers. For example, the old Roman numbering system can't support the value 5000 and beyond. For those unsupported cases, the default number format from CLDR is used.
1339*912701f9SAndroid Build Coastguard Worker
1340*912701f9SAndroid Build Coastguard WorkerAny rules marked as **private** should never be referenced externally. Frequently they only support a subrange of numbers that are used in the public rules.
1341*912701f9SAndroid Build Coastguard Worker
1342*912701f9SAndroid Build Coastguard WorkerThe syntax used in the CLDR representation of rules is intended to be simply a transcription of ICU based RBNF rules into an XML compatible syntax. The rules are fairly sophisticated; for details see _Rule-Based Number Formatter_ [[RBNF](tr35.md#RBNF)].
1343*912701f9SAndroid Build Coastguard Worker
1344*912701f9SAndroid Build Coastguard Worker```xml
1345*912701f9SAndroid Build Coastguard Worker<ruleSetGrouping>
1346*912701f9SAndroid Build Coastguard Worker```
1347*912701f9SAndroid Build Coastguard Worker
1348*912701f9SAndroid Build Coastguard WorkerUsed to group rules into functional sets for use with ICU. Currently, the valid types of rule set groupings are "SpelloutRules", "OrdinalRules", and "NumberingSystemRules".
1349*912701f9SAndroid Build Coastguard Worker
1350*912701f9SAndroid Build Coastguard Worker```xml
1351*912701f9SAndroid Build Coastguard Worker<ruleset>
1352*912701f9SAndroid Build Coastguard Worker```
1353*912701f9SAndroid Build Coastguard Worker
1354*912701f9SAndroid Build Coastguard WorkerThis element denotes a specific rule set to the number formatter. The ruleset is assumed to be a public ruleset unless the attribute type="private" is specified.
1355*912701f9SAndroid Build Coastguard Worker
1356*912701f9SAndroid Build Coastguard Worker```xml
1357*912701f9SAndroid Build Coastguard Worker<rule>
1358*912701f9SAndroid Build Coastguard Worker```
1359*912701f9SAndroid Build Coastguard Worker
1360*912701f9SAndroid Build Coastguard WorkerContains the actual formatting rule for a particular number or sequence of numbers. The `value` attribute is used to indicate the starting number to which the rule applies. The actual text of the rule is identical to the ICU syntax, with the exception that Unicode left and right arrow characters are used to replace < and > in the rule text, since < and > are reserved characters in XML. The `radix` attribute is used to indicate an alternate radix to be used in calculating the prefix and postfix values for number formatting. Alternate radix values are typically used for formatting year numbers in formal documents, such as "nineteen hundred seventy-six" instead of "one thousand nine hundred seventy-six".
1361*912701f9SAndroid Build Coastguard Worker
1362*912701f9SAndroid Build Coastguard Worker## <a name="Parsing_Numbers" href="#Parsing_Numbers">Parsing Numbers</a>
1363*912701f9SAndroid Build Coastguard Worker
1364*912701f9SAndroid Build Coastguard WorkerThe following elements are relevant to determining the value of a parsed number:
1365*912701f9SAndroid Build Coastguard Worker
1366*912701f9SAndroid Build Coastguard Worker* A possible prefix or suffix, indicating sign
1367*912701f9SAndroid Build Coastguard Worker* A possible currency symbol or code
1368*912701f9SAndroid Build Coastguard Worker* Decimal digits
1369*912701f9SAndroid Build Coastguard Worker* A possible decimal separator
1370*912701f9SAndroid Build Coastguard Worker* A possible exponent
1371*912701f9SAndroid Build Coastguard Worker* A possible percent or per mille character
1372*912701f9SAndroid Build Coastguard Worker
1373*912701f9SAndroid Build Coastguard WorkerOther characters should either be ignored, or indicate the end of input, depending on the application. The key point is to disambiguate the sets of characters that might serve in more than one position, based on context. For example, a period might be either the decimal separator, or part of a currency symbol (for example, "NA f."). Similarly, an "E" could be an exponent indicator, or a currency symbol (the Swaziland Lilangeni uses "E" in the "en" locale). An apostrophe might be the decimal separator, or might be the grouping separator.
1374*912701f9SAndroid Build Coastguard Worker
1375*912701f9SAndroid Build Coastguard WorkerHere is a set of heuristic rules that may be helpful:
1376*912701f9SAndroid Build Coastguard Worker
1377*912701f9SAndroid Build Coastguard Worker* Any character with the decimal digit property is unambiguous and should be accepted.
1378*912701f9SAndroid Build Coastguard Worker
1379*912701f9SAndroid Build Coastguard Worker  **Note:** In some environments, applications may independently wish to restrict the decimal digit set to prevent security problems. See [[UTR36](https://www.unicode.org/reports/tr41/#UTR36)].
1380*912701f9SAndroid Build Coastguard Worker
1381*912701f9SAndroid Build Coastguard Worker* The exponent character can only be interpreted as such if it occurs after at least one digit, and if it is followed by at least one digit, with only an optional sign in between. A regular expression may be helpful here.
1382*912701f9SAndroid Build Coastguard Worker* For the sign, decimal separator, percent, and per mille, use a set of all possible characters that can serve those functions. For example, the decimal separator set could include all of [.,']. (The actual set of characters can be derived from the number symbols in the By-Type charts [[ByType](tr35.md#ByType)], which list all of the values in CLDR.) To disambiguate, the decimal separator for the locale must be removed from the "ignore" set, and the grouping separator for the locale must be removed from the decimal separator set. The same principle applies to all sets and symbols: any symbol must appear in at most one set.
1383*912701f9SAndroid Build Coastguard Worker* Since there are a wide variety of currency symbols and codes, this should be tried before the less ambiguous elements. It may be helpful to develop a set of characters that can appear in a symbol or code, based on the currency symbols in the locale.
1384*912701f9SAndroid Build Coastguard Worker* Otherwise, a character should be ignored unless it is in the "stop" set. This includes even characters that are meaningful for formatting, for example, the grouping separator.
1385*912701f9SAndroid Build Coastguard Worker* If more than one sign, currency symbol, exponent, or percent/per mille occurs in the input, the first found should be used.
1386*912701f9SAndroid Build Coastguard Worker* A currency symbol in the input should be interpreted as the longest match found in the set of possible currency symbols.
1387*912701f9SAndroid Build Coastguard Worker* Especially in cases of ambiguity, the user's input should be echoed back, properly formatted according to the locale, before it is actually used for anything.
1388*912701f9SAndroid Build Coastguard Worker
1389*912701f9SAndroid Build Coastguard Worker## <a name="Number_Range_Formatting" href="#Number_Range_Formatting">Number Range Formatting</a>
1390*912701f9SAndroid Build Coastguard Worker
1391*912701f9SAndroid Build Coastguard WorkerOften ranges of numbers are presented to users, such as in “Length: 3.2–4.5 centimeters”. This means any length from 3.2 cm to 4.5 cm, inclusive.
1392*912701f9SAndroid Build Coastguard Worker
1393*912701f9SAndroid Build Coastguard WorkerTo format a number range, the following steps are taken:
1394*912701f9SAndroid Build Coastguard Worker
1395*912701f9SAndroid Build Coastguard Worker1. Format the lower bound and the upper bound independently following the steps in [Number Format Patterns](#Number_Format_Patterns), preserving semantic annotations\*.
1396*912701f9SAndroid Build Coastguard Worker1. If the resulting values are identical, stop evaluating these steps and, instead, perform the steps in [Approximate Number Formatting](#Approximate_Number_Formatting).
1397*912701f9SAndroid Build Coastguard Worker    1. Note: This behavior may be customized in order to, for example, print the range despite the endpoints being identical. However, a spec-compliant implementation must support approximate number formatting.
1398*912701f9SAndroid Build Coastguard Worker1. Perform the steps in [Collapsing Number Ranges](#Collapsing_Number_Ranges), obtaining modified *lower* and *upper* values.
1399*912701f9SAndroid Build Coastguard Worker1. Obtain a number range pattern by following the steps in [Range Pattern Processing](#Range_Pattern_Processing).
1400*912701f9SAndroid Build Coastguard Worker1. Substitute *lower* as `{0}` and *upper* as `{1}` into the range pattern from the previous step.
1401*912701f9SAndroid Build Coastguard Worker
1402*912701f9SAndroid Build Coastguard Worker\* Semantic annotations are discussed in [Collapsing Number Ranges](#Collapsing_Number_Ranges).
1403*912701f9SAndroid Build Coastguard Worker
1404*912701f9SAndroid Build Coastguard WorkerFor plural rule selection of number ranges, see [Plural Ranges](#Plural_Ranges).
1405*912701f9SAndroid Build Coastguard Worker
1406*912701f9SAndroid Build Coastguard Worker### <a name="Approximate_Number_Formatting" href="#Approximate_Number_Formatting">Approximate Number Formatting</a>
1407*912701f9SAndroid Build Coastguard Worker
1408*912701f9SAndroid Build Coastguard Worker*Approximate number formatting* refers to a specific format of numbers in which the value is understood to not be exact; for example, "\~5 minutes".
1409*912701f9SAndroid Build Coastguard Worker
1410*912701f9SAndroid Build Coastguard WorkerTo format an approximate number, follow the normal number formatting procedure in [Number Format Patterns](#Number_Format_Patterns), but substitute the `approximatelySign` from [Number Symbols](#Number_Symbols) in for the minus sign placeholder.
1411*912701f9SAndroid Build Coastguard Worker
1412*912701f9SAndroid Build Coastguard WorkerIf the number is negative, or if the formatting options request the sign to be displayed, *prepend* the `approximatelySign` to the plus or minus sign before substituting it into the pattern. For example, "\~-5" means "approximately negative five". This procedure may change in the future.
1413*912701f9SAndroid Build Coastguard Worker
1414*912701f9SAndroid Build Coastguard Worker### <a name="Collapsing_Number_Ranges" href="#Collapsing_Number_Ranges">Collapsing Number Ranges</a>
1415*912701f9SAndroid Build Coastguard Worker
1416*912701f9SAndroid Build Coastguard Worker*Collapsing* a number range refers to the process of removing duplicated information in the *lower* and *upper* values. For example, if the lower string is "3.2 centimeters" and the upper string is "4.5 centimeters", it is desirable to remove the extra "centimeters" token.
1417*912701f9SAndroid Build Coastguard Worker
1418*912701f9SAndroid Build Coastguard WorkerThis operation requires *semantic annotations* on the formatted value. The exact form of the semantic annotations is implementation-dependent. However, implementations may consider the following broad categories of tokens:
1419*912701f9SAndroid Build Coastguard Worker
1420*912701f9SAndroid Build Coastguard Worker1. Numerical value, including decimal and grouping separators
1421*912701f9SAndroid Build Coastguard Worker1. Sign symbol
1422*912701f9SAndroid Build Coastguard Worker1. Scientific or compact notation
1423*912701f9SAndroid Build Coastguard Worker1. Unit of measurement
1424*912701f9SAndroid Build Coastguard Worker
1425*912701f9SAndroid Build Coastguard WorkerFor example, consider the string `-5.3M US dollars`. It may be annotated as follows:
1426*912701f9SAndroid Build Coastguard Worker
1427*912701f9SAndroid Build Coastguard Worker- `-` → sign symbol
1428*912701f9SAndroid Build Coastguard Worker- `5.3` → numerical value
1429*912701f9SAndroid Build Coastguard Worker- `M` → compact notation
1430*912701f9SAndroid Build Coastguard Worker- `US dollars` → unit of measurement for the currency USD
1431*912701f9SAndroid Build Coastguard Worker
1432*912701f9SAndroid Build Coastguard WorkerTwo tokens are *semantically equivalent* if they have the same *semantic annotations*, even if they are not the exact same string. For example:
1433*912701f9SAndroid Build Coastguard Worker
1434*912701f9SAndroid Build Coastguard Worker1. "centimeter" is semantically equivalent to "centimeters".
1435*912701f9SAndroid Build Coastguard Worker1. "K" (the thousands symbol in compact decimals) is NOT semantically equivalent to "K" (the measurement unit Kelvin).
1436*912701f9SAndroid Build Coastguard Worker
1437*912701f9SAndroid Build Coastguard WorkerThe above description describes the expected output. Internally, the implementation may determine the equivalent units of measurement by passing the codes back from the number formatters, allowing for a precise determination of "semantically equivalent".
1438*912701f9SAndroid Build Coastguard Worker
1439*912701f9SAndroid Build Coastguard WorkerTwo semantically equivalent tokens can be *collapsed* if they appear at the start of both values or the end of both values.
1440*912701f9SAndroid Build Coastguard WorkerHowever, the implementation may choose different levels of aggressiveness with regard to collapsing tokens.
1441*912701f9SAndroid Build Coastguard WorkerAn API for displaying ranges should permit control over whether the tokens are collapsed or not, and the levels of aggressiveness.
1442*912701f9SAndroid Build Coastguard WorkerThe currently recommended heuristic is:
1443*912701f9SAndroid Build Coastguard Worker
1444*912701f9SAndroid Build Coastguard Worker1. Never collapse scientific or compact notation. This is to avoid producing ambiguous strings such as "3–5M" (could represent 3–5,000,000 or 3,000,000–5,000,000).
1445*912701f9SAndroid Build Coastguard Worker2. Only collapse if the tokens are more than one code point in length. This is to increase clarity of strings such as "$3–$5".
1446*912701f9SAndroid Build Coastguard Worker3. To perform the collapse, remove the token that is closest to the range separator.
1447*912701f9SAndroid Build Coastguard WorkerThat is, for a prefix element, remove from the end value of the range, and for a suffix element remove it from the start value of the range:
1448*912701f9SAndroid Build Coastguard Worker    * USD 2 – USD 5 ⇒ USD 2 – 5
1449*912701f9SAndroid Build Coastguard Worker    * 2M EUR – 5M EUR ⇒  2M – 5M EUR
1450*912701f9SAndroid Build Coastguard Worker    * 2 km – 5 km ⇒ 2 – 5 km
1451*912701f9SAndroid Build Coastguard Worker    * 2M ft – 5M ft ⇒ 2M – 5M ft
1452*912701f9SAndroid Build Coastguard Worker4. When the tokens can have distinct plural forms, modify the remaining token so that it has the correct plural form. That is, use [Plural Ranges](#Plural_Ranges) to calculate the correct plural category for the range, and pick the variant of that the remaining token corresponding to that plural form.
1453*912701f9SAndroid Build Coastguard Worker
1454*912701f9SAndroid Build Coastguard WorkerIn bidi contexts, the data is built so that rule #3 works **visually**.
1455*912701f9SAndroid Build Coastguard WorkerFor example, if a range from 2 km to 5 km would be presented visually as "_mk 5 – mk 2_", the collapsed form would be "_mk 5 – 2_".
1456*912701f9SAndroid Build Coastguard Worker(The _mk_ is a stand-in for the native representation.)
1457*912701f9SAndroid Build Coastguard WorkerThis requires consistent visualy reordering among the elements: the range, the prefixes and the suffixes.
1458*912701f9SAndroid Build Coastguard WorkerThus a prefix value will be reordered to be visually a suffix value, and the order of the range will be visually reversed.
1459*912701f9SAndroid Build Coastguard Worker
1460*912701f9SAndroid Build Coastguard Worker### <a name="Range_Pattern_Processing" href="#Range_Pattern_Processing">Range Pattern Processing</a>
1461*912701f9SAndroid Build Coastguard Worker
1462*912701f9SAndroid Build Coastguard WorkerTo obtain a number range pattern, the following steps are taken:
1463*912701f9SAndroid Build Coastguard Worker
1464*912701f9SAndroid Build Coastguard Worker1. Load the range pattern found in [Miscellaneous Patterns](#Miscellaneous_Patterns).
1465*912701f9SAndroid Build Coastguard Worker1. Optionally add spacing to the range pattern.
1466*912701f9SAndroid Build Coastguard Worker
1467*912701f9SAndroid Build Coastguard WorkerTo determine whether to add spacing, the currently recommended heuristic is:
1468*912701f9SAndroid Build Coastguard Worker
1469*912701f9SAndroid Build Coastguard Worker1. If the *lower* string ends with a character other than a digit, or if the *upper* string begins with a character other than a digit.
1470*912701f9SAndroid Build Coastguard Worker2. If the range pattern does not contain a character having the `White_Space` binary Unicode property after the `{0}` or before the `{1}` placeholders.
1471*912701f9SAndroid Build Coastguard Worker
1472*912701f9SAndroid Build Coastguard WorkerThese heuristics may be refined in the future.
1473*912701f9SAndroid Build Coastguard Worker
1474*912701f9SAndroid Build Coastguard WorkerTo add spacing, insert a non-breaking space (U+00A0) at the positions in item 2 above.
1475*912701f9SAndroid Build Coastguard Worker
1476*912701f9SAndroid Build Coastguard Worker* * *
1477*912701f9SAndroid Build Coastguard Worker
1478*912701f9SAndroid Build Coastguard WorkerCopyright © 2001–2024 Unicode, Inc. All Rights Reserved. The Unicode Consortium makes no expressed or implied warranty of any kind, and assumes no liability for errors or omissions. No liability is assumed for incidental and consequential damages in connection with or arising out of the use of the information or programs contained or accompanying this technical report. The Unicode [Terms of Use](https://www.unicode.org/copyright.html) apply.
1479*912701f9SAndroid Build Coastguard Worker
1480*912701f9SAndroid Build Coastguard WorkerUnicode and the Unicode logo are trademarks of Unicode, Inc., and are registered in some jurisdictions.
1481