1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 2"http://www.w3.org/TR/html4/loose.dtd"> 3<html> 4 5<head> 6<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 7<meta http-equiv="Content-Language" content="en-us"> 8<link rel="stylesheet" href="http://www.unicode.org/reports/reports.css" 9 type="text/css"> 10<title>UTS #35: Unicode LDML: Numbers</title> 11<style type="text/css"> 12<!-- 13.dtd { 14 font-family: monospace; 15 font-size: 90%; 16 background-color: #CCCCFF; 17 border-style: dotted; 18 border-width: 1px; 19} 20 21.xmlExample { 22 font-family: monospace; 23 font-size: 80% 24} 25 26.blockedInherited { 27 font-style: italic; 28 font-weight: bold; 29 border-style: dashed; 30 border-width: 1px; 31 background-color: #FF0000 32} 33 34.inherited { 35 font-weight: bold; 36 border-style: dashed; 37 border-width: 1px; 38 background-color: #00FF00 39} 40 41.element { 42 font-weight: bold; 43 color: red; 44} 45 46.attribute { 47 font-weight: bold; 48 color: maroon; 49} 50 51.attributeValue { 52 font-weight: bold; 53 color: blue; 54} 55 56li, p { 57 margin-top: 0.5em; 58 margin-bottom: 0.5em 59} 60 61h2, h3, h4, table { 62 margin-top: 1.5em; 63 margin-bottom: 0.5em; 64} 65--> 66</style> 67</head> 68 69<body> 70 71 <table class="header" width="100%"> 72 <tr> 73 <td class="icon"><a href="http://unicode.org"> <img 74 alt="[Unicode]" src="http://unicode.org/webscripts/logo60s2.gif" 75 width="34" height="33" 76 style="vertical-align: middle; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px; border-top-width: 0px;"></a> 77 <a class="bar" href="http://www.unicode.org/reports/">Technical 78 Reports</a></td> 79 </tr> 80 <tr> 81 <td class="gray"> </td> 82 </tr> 83 </table> 84 <div class="body"> 85 <h2 style="text-align: center"> 86 Unicode Technical 87 Standard #35 88 </h2> 89 <h1 style="text-align: center"> 90 Unicode Locale Data Markup Language (LDML)<br> Part 3: Numbers 91 </h1> 92 93 <!-- At least the first row of this header table should be identical across the parts of this UTS. --> 94 <table border="1" cellpadding="2" cellspacing="0" class="wide"> 95 <tr> 96 <td>Version</td> 97 <td>34</td> 98 </tr> 99 <tr> 100 <td>Editors</td> 101 <td>John Emmons (<a href="mailto:emmo@us.ibm.com">emmo@us.ibm.com</a>) 102 and <a href="tr35.html#Acknowledgments">other CLDR committee 103 members</a></td> 104 </tr> 105 </table> 106 107 <p> 108 For the full header, summary, and status, see <a href="tr35.html"> 109 Part 1: Core</a> 110 </p> 111 112 <h3> 113 <i>Summary</i> 114 </h3> 115 <p> 116 This document describes parts of an XML format (<i>vocabulary</i>) 117 for the exchange of structured locale data. This format is used in 118 the <a href="http://cldr.unicode.org/">Unicode Common Locale Data 119 Repository</a>. 120 </p> 121 122 <p> 123 This is a partial document, describing only those parts of the LDML 124 that are relevant for number and currency formatting. For the other 125 parts of the LDML see the <a href="tr35.html">main LDML document</a> 126 and the links above. 127 </p> 128 129 <h3> 130 <i>Status</i> 131 </h3> 132 133 <!-- NOT YET APPROVED 134 <p> 135 <i class="changed">This is a<b><font color="#ff3333"> 136 draft </font></b>document which may be updated, replaced, or superseded by 137 other documents at any time. Publication does not imply endorsement 138 by the Unicode Consortium. This is not a stable document; it is 139 inappropriate to cite this document as other than a work in 140 progress. 141 </i> 142 </p> 143 END NOT YET APPROVED --> 144 <!-- APPROVED --> 145 <p> 146 <i>This document has been reviewed by Unicode members and other 147 interested parties, and has been approved for publication by the 148 Unicode Consortium. This is a stable document and may be used as 149 reference material or cited as a normative reference by other 150 specifications.</i> 151 </p> 152 <!-- END APPROVED --> 153 154 <blockquote> 155 <p> 156 <i><b>A Unicode Technical Standard (UTS)</b> is an independent 157 specification. Conformance to the Unicode Standard does not imply 158 conformance to any UTS.</i> 159 </p> 160 </blockquote> 161 <p> 162 <i>Please submit corrigenda and other comments with the CLDR bug 163 reporting form [<a href="tr35.html#Bugs">Bugs</a>]. Related 164 information that is useful in understanding this document is found 165 in the <a href="tr35.html#References">References</a>. For the latest 166 version of the Unicode Standard see [<a href="tr35.html#Unicode">Unicode</a>]. 167 For a list of current Unicode Technical Reports see [<a 168 href="tr35.html#Reports">Reports</a>]. For more information about 169 versions of the Unicode Standard, see [<a href="tr35.html#Versions">Versions</a>]. 170 </i> 171 </p> 172 173 <!-- This section of Parts should be identical in all of the parts of this UTS. --> 174 <h2> 175 <a name="Parts" href="#Parts">Parts</a> 176 </h2> 177 <p>The LDML specification is divided into the following parts:</p> 178 <ul class="toc"> 179 <li>Part 1: <a href="tr35.html#Contents">Core</a> (languages, 180 locales, basic structure) 181 </li> 182 <li>Part 2: <a href="tr35-general.html#Contents">General</a> 183 (display names & transforms, etc.) 184 </li> 185 <li>Part 3: <a href="tr35-numbers.html#Contents">Numbers</a> 186 (number & currency formatting) 187 </li> 188 <li>Part 4: <a href="tr35-dates.html#Contents">Dates</a> (date, 189 time, time zone formatting) 190 </li> 191 <li>Part 5: <a href="tr35-collation.html#Contents">Collation</a> 192 (sorting, searching, grouping) 193 </li> 194 <li>Part 6: <a href="tr35-info.html#Contents">Supplemental</a> 195 (supplemental data) 196 </li> 197 <li>Part 7: <a href="tr35-keyboards.html#Contents">Keyboards</a> 198 (keyboard mappings) 199 </li> 200 </ul> 201 <h2> 202 <a name="Contents" href="#Contents">Contents of Part 3, Numbers</a> 203 </h2> 204 <!-- START Generated TOC: CheckHtmlFiles --> 205 <ul class="toc"> 206 <li>1 <a href="#Numbering_Systems">Numbering Systems</a></li> 207 <li>2 <a href="#Number_Elements">Number Elements</a> 208 <ul class="toc"> 209 <li>2.1 <a href="#defaultNumberingSystem">Default 210 Numbering System</a></li> 211 <li>2.2 <a href="#otherNumberingSystems">Other Numbering 212 Systems</a></li> 213 <li>2.3 <a href="#Number_Symbols">Number Symbols</a></li> 214 <li>2.4 <a href="#Number_Formats">Number Formats</a> 215 <ul class="toc"> 216 <li>2.4.1 <a href="#Compact_Number_Formats">Compact 217 Number Formats</a></li> 218 <li>2.4.2 <a href="#Currency_Formats">Currency Formats</a></li> 219 </ul> 220 </li> 221 <li>2.5 <a href="#Miscellaneous_Patterns">Miscellaneous 222 Patterns</a></li> 223 <li>2.6 <a href="#Minimal_Pairs">Minimal Pairs</a></li> 224 </ul> 225 </li> 226 <li>3 <a href="#Number_Format_Patterns">Number Format 227 Patterns</a> 228 <ul class="toc"> 229 <li>3.1 <a href="#Number_Patterns">Number Patterns</a> 230 <ul class="toc"> 231 <li>Table: <a href="#Number_Pattern_Examples">Number 232 Pattern Examples</a></li> 233 </ul> 234 </li> 235 <li>3.2 <a href="#Special_Pattern_Characters">Special 236 Pattern Characters</a> 237 <ul class="toc"> 238 <li>Table: <a href="#Number_Pattern_Character_Definitions">Number 239 Pattern Character Definitions</a></li> 240 <li>Table: <a href="#Sample_Patterns_and_Results">Sample 241 Patterns and Results</a></li> 242 <li>Table: <a href="#Examples_of_minimumGroupingDigits">Examples 243 of minimumGroupingDigits</a></li> 244 <li>3.2.1 <a href="#Explicit_Plus">Explicit Plus Signs</a></li> 245 </ul> 246 </li> 247 <li>3.3 <a href="#Formatting">Formatting</a></li> 248 <li>3.4 <a href="#sci">Scientific Notation</a></li> 249 <li>3.5 <a href="#sigdig">Significant Digits</a> 250 <ul class="toc"> 251 <li>Table: <a href="#Significant_Digits_Examples">Significant 252 Digits Examples</a></li> 253 </ul> 254 </li> 255 <li>3.6 <a href="#Padding">Padding</a></li> 256 <li>3.7 <a href="#Rounding">Rounding</a></li> 257 <li>3.8 <a href="#Quoting_Rules">Quoting Rules</a></li> 258 </ul> 259 </li> 260 <li>4 <a href="#Currencies">Currencies</a> 261 <ul class="toc"> 262 <li>4.1 <a href="#Supplemental_Currency_Data">Supplemental 263 Currency Data</a></li> 264 </ul> 265 </li> 266 <li>5 <a href="#Language_Plural_Rules">Language Plural Rules</a> 267 <ul class="toc"> 268 <li>5.1 <a href="#Plural_rules_syntax">Plural rules syntax</a> 269 <ul class="toc"> 270 <li>5.1.1 <a href="#Operands">Operands</a> 271 <ul class="toc"> 272 <li>Table: <a href="#Plural_Operand_Meanings">Plural 273 Operand Meanings</a></li> 274 <li>Table: <a href="#Plural_Operand_Examples">Plural 275 Operand Examples</a></li> 276 </ul> 277 </li> 278 <li>5.1.2 <a href="#Relations">Relations</a> 279 <ul class="toc"> 280 <li>Table: <a href="#Relations_Examples">Relations 281 Examples</a></li> 282 <li>Table: <a href="#Plural_Rules_Examples">Plural 283 Rules Examples</a></li> 284 </ul> 285 </li> 286 <li>5.1.3 <a href="#Samples">Samples</a> 287 <ul class="toc"> 288 <li>Table: <a href="#Plural_Samples_Examples">Plural 289 Samples Examples</a></li> 290 </ul> 291 </li> 292 <li>5.1.4 <a href="#Using_cardinals">Using Cardinals</a></li> 293 </ul> 294 </li> 295 <li>5.2 <a href="#Plural_Ranges">Plural Ranges</a></li> 296 </ul> 297 </li> 298 <li>6 <a href="#Rule-Based_Number_Formatting">Rule-Based 299 Number Formatting</a></li> 300 <li>7 <a href="#Parsing_Numbers">Parsing Numbers</a></li> 301 </ul> 302 <!-- END Generated TOC: CheckHtmlFiles --> 303 <h2> 304 <a name="Numbering_Systems" href="#Numbering_Systems">1 Numbering 305 Systems</a> 306 </h2> 307 <p class="dtd"> 308 <!ELEMENT numberingSystems ( numberingSystem* ) ><br> 309 <!ELEMENT numberingSystem EMPTY ><br> <!ATTLIST 310 numberingSystem id NMTOKEN #REQUIRED ><br> <!ATTLIST 311 numberingSystem type ( numeric | algorithmic ) #REQUIRED ><br> 312 <!ATTLIST numberingSystem radix NMTOKEN #IMPLIED ><br> 313 <!ATTLIST numberingSystem digits CDATA #IMPLIED ><br> 314 <!ATTLIST numberingSystem rules CDATA #IMPLIED ><br> 315 </p> 316 <p> 317 Numbering systems information is used to define different 318 representations for numeric values to an end user. Numbering systems 319 are defined in CLDR as one of two different types: algorithmic and 320 numeric. Numeric systems are simply a decimal based system that uses 321 a predefined set of digits to represent numbers. Examples are Western 322 ( ASCII digits ), Thai digits, Devanagari digits. Algorithmic systems 323 are more complex in nature, since the proper formatting and 324 presentation of a numeric quantity is based on some algorithm or set 325 of rules. Examples are Chinese numerals, Hebrew numerals, or Roman 326 numerals. In CLDR, the rules for presentation of numbers in an 327 algorithmic system are defined using the RBNF syntax described in <i><a 328 href="#Rule-Based_Number_Formatting">Section 6: Rule-Based 329 Number Formatting</a></i>. 330 </p> 331 <p>Attributes for the <numberingSystem> element are as 332 follows:</p> 333 <blockquote> 334 <p> 335 <span class="attribute">id</span> - Specifies the name of the 336 numbering system that can be used to designate its use in 337 formatting. 338 </p> 339 <p> 340 <span class="attribute">type</span> - Specifies whether the 341 numbering system is algorithmic or numeric. 342 </p> 343 <p> 344 <span class="attribute">digits</span> - For numeric systems, 345 specifies the digits used to represent numbers, in order, starting 346 from zero. 347 </p> 348 <p> 349 <span class="attribute">rules</span> - Specifies the RBNF ruleset to 350 be used for formatting numbers from this numbering system. The rules 351 specifier can contain simply a ruleset name, in which case the 352 ruleset is assumed to be found in the rule set grouping 353 "NumberingSystemRules". Alternatively, the specifier can 354 denote a specific locale, ruleset grouping, and ruleset name, 355 separated by slashes. 356 </p> 357 </blockquote> 358 <p>Examples:</p> 359 <pre><numberingSystem id="latn" type="numeric" digits="0123456789"/> 360<!-- ASCII digits - A numeric system --></pre> 361 <pre><numberingSystem id="thai" type="numeric" digits="๐๑๒๓๔๕๖๗๘๙"/> 362<!-- A numeric system using Thai digits --></pre> 363 <pre><numberingSystem id="geor" type="algorithmic" rules="georgian"/> 364<!-- An algorithmic system - Georgian numerals , rules found in NumberingSystemRules --></pre> 365 <pre><numberingSystem id="hant" type="algorithmic" rules="zh_Hant/SpelloutRules/spellout-cardinal"/> 366<!-- An algorithmic system. Traditional Chinese Numerals --> 367</pre> 368 For general information about the numbering system data, including the 369 BCP47 identifiers, see the main document <em>Section Q.1.1 <a 370 href="tr35.html#Numbering System Data">Numbering System Data</a>. 371 </em> ) ><br> 372 <h2> 373 <a name="Number_Elements" href="#Number_Elements">2 Number 374 Elements</a> 375 </h2> 376 <p class="dtd"><!ELEMENT numbers ( alias | ( defaultNumberingSystem*, otherNumberingSystems*, minimumGroupingDigits*, symbols*, decimalFormats*, scientificFormats*, percentFormats*, currencyFormats*, currencies?, miscPatterns*, minimalPairs*, special* ) ) ></p> 377 <p> 378 The numbers element supplies information for formatting and parsing 379 numbers and currencies. It has the following sub-elements: 380 <defaultNumberingSystem>, <otherNumberingSystems>, 381 <symbols>, <decimalFormats>, <scientificFormats>, 382 <percentFormats>, <currencyFormats>, and 383 <currencies>. The currency IDs are from [<a 384 href="tr35.html#ISO4217">ISO4217</a>] (plus some additional 385 common-use codes). For more information, including the pattern 386 structure, see <i><a href="#Number_Format_Patterns">Section 387 3: Number Format Patterns</a></i>. 388 </p> 389 <h3> 390 2.1 <a name="defaultNumberingSystem" href="#defaultNumberingSystem">Default 391 Numbering System</a> 392 </h3> 393 <p> 394 <span class="dtd"><!ELEMENT defaultNumberingSystem ( 395 #PCDATA )></span> 396 </p> 397 <p>This element indicates which numbering system should be used 398 for presentation of numeric quantities in the given locale.</p> 399 <h3> 400 2.2 <a name="otherNumberingSystems" href="#otherNumberingSystems">Other 401 Numbering Systems</a> 402 </h3> 403 <p> 404 <span class="dtd"><!ELEMENT otherNumberingSystems ( alias | 405 ( native*, traditional*, finance*)) ></span> 406 </p> 407 <p>This element defines general categories of numbering systems 408 that are sometimes used in the given locale for formatting numeric 409 quantities. These additional numbering systems are often used in very 410 specific contexts, such as in calendars or for financial purposes. 411 There are currently three defined categories, as follows:</p> 412 <dl> 413 <dt> 414 <b>native</b> 415 </dt> 416 <dd>Defines the numbering system used for the native digits, 417 usually defined as a part of the script used to write the language. 418 The native numbering system can only be a numeric positional 419 decimal-digit numbering system, using digits with 420 General_Category=Decimal_Number. Note: In locales where the native 421 numbering system is the default, it is assumed that the numbering 422 system "latn" ( Western Digits 0-9 ) is always acceptable, and can 423 be selected using the -nu keyword as part of a Unicode locale 424 identifier.</dd> 425 <dt> 426 <b>traditional</b> 427 </dt> 428 <dd>Defines the traditional numerals for a locale. This 429 numbering system may be numeric or algorithmic. If the traditional 430 numbering system is not defined, applications should use the native 431 numbering system as a fallback.</dd> 432 <dt> 433 <b>finance</b> 434 </dt> 435 <dd>Defines the numbering system used for financial quantities. 436 This numbering system may be numeric or algorithmic. This is often 437 used for ideographic languages such as Chinese, where it would be 438 easy to alter an amount represented in the default numbering system 439 simply by adding additional strokes. If the financial numbering 440 system is not specified, applications should use the default 441 numbering system as a fallback.</dd> 442 </dl> 443 <p>The categories defined for other numbering systems can be used 444 in a Unicode locale identifier to select the proper numbering system 445 without having to know the specific numbering system by name. For 446 example:</p> 447 <ul> 448 <li>To select Hindi language using the native digits for numeric 449 formatting, use locale ID: "hi-IN-u-nu-native".</li> 450 <li>To select Chinese language using the appropriate financial 451 numerals, use locale ID: "zh-u-nu-finance".</li> 452 <li>To select Tamil language using the traditional Tamil 453 numerals, use locale ID: "ta-u-nu-traditio".</li> 454 <li>To select Arabic language using western digits 0-9, use 455 locale ID: "ar-u-nu-latn".</li> 456 </ul> 457 <p> 458 For more information on numbering systems and their definitions, see 459 <i><a href="#Numbering_Systems">Section 1: Numbering Systems</a></i>. 460 </p> 461 462 <h3> 463 2.3 <a name="Number_Symbols" href="#Number_Symbols">Number 464 Symbols</a> 465 </h3> 466 <p class="dtd"><!ELEMENT symbols (alias | (decimal*, group*, 467 list*, percentSign*, nativeZeroDigit*, patternDigit*, plusSign*, 468 minusSign*, exponential*, superscriptingExponent*, perMille*, 469 infinity*, nan*, currencyDecimal*, currencyGroup*, timeSeparator*, 470 special*)) ></p> 471 <p> 472 Number symbols define the localized symbols that are commonly used 473 when formatting numbers in a given locale. These symbols can be 474 referenced using a number formatting pattern as defined in <i><a 475 href="#Number_Format_Patterns">Section 3: Number Format Patterns</a></i>. 476 </p> 477 <p>The available number symbols are as follows:</p> 478 <dl> 479 <dt> 480 <b>decimal</b> 481 </dt> 482 <dd>- separates the integer and fractional part of the number.</dd> 483 <dt> 484 <b>group</b> 485 </dt> 486 <dd> 487 - separates clusters of integer digits to make large numbers more 488 legible; commonly used for thousands (grouping size 3, e.g. 489 "100,000,000") or in some locales, ten-thousands (grouping 490 size 4, e.g. "1,0000,0000"). There may be two different 491 grouping sizes: The <em>primary grouping size</em> used for the 492 least significant integer group, and the <em>secondary grouping 493 size</em> used for more significant groups; these are not the same in 494 all locales (e.g. "12,34,56,789"). If a pattern contains 495 multiple grouping separators, the interval between the last one and 496 the end of the integer defines the primary grouping size, and the 497 interval between the last two defines the secondary grouping size. 498 All others are ignored, so "#,##,###,####" == 499 "###,###,####" == "##,#,###,####". 500 </dd> 501 <dt> 502 <b>list</b> 503 </dt> 504 <dd> 505 - symbol used to separate numbers in a list intended to represent 506 structured data such as an array; must be different from the <b>decimal</b> 507 value. This list separator is for “non-linguistic” usage as opposed 508 to the listPatterns for “linguistic” lists (e.g. “Bob, Carol, and 509 Ted”) described in Part 2, <em>Section 11 <a 510 href="tr35-general.html#ListPatterns">List Patterns</a></em>. 511 </dd> 512 <dt> 513 <b>percentSign</b> 514 </dt> 515 <dd>- symbol used to indicate a percentage (1/100th) amount. (If 516 present, the value is also multiplied by 100 before formatting. That 517 way 1.23 → 123%)</dd> 518 <dt> 519 <b>nativeZeroDigit</b> 520 </dt> 521 <dd>- Deprecated - do not use.</dd> 522 <dt> 523 <b>patternDigit</b> 524 </dt> 525 <dd> 526 - Deprecated. This was formerly used to provide the localized 527 pattern character corresponding to '#', but localization of the 528 pattern characters themselves has been deprecated for some time 529 (determining the locale-specific <em>replacements</em> for pattern 530 characters is of course not deprecated and is part of normal number 531 formatting). 532 </dd> 533 <dt> 534 <b>minusSign</b> 535 </dt> 536 <dd>- Symbol used to denote negative value.</dd> 537 <dt> 538 <b>plusSign</b> 539 </dt> 540 <dd>- Symbol used to denote positive value. It can be used 541 to produce modified patterns, so that 3.12 is formatted as "+3.12", 542 for example. The standard number patterns (except for 543 type="accounting") will contain the minusSign, explicitly or 544 implicitly. In the explicit pattern, the value of the plusSign can 545 be substituted for the value of the minusSign to produce a pattern 546 that has an explicit plus sign.</dd> 547 <dt> 548 <b>exponential</b> 549 </dt> 550 <dd>- Symbol separating the mantissa and exponent values.</dd> 551 <dt> 552 <b>superscriptingExponent</b> 553 </dt> 554 <dd> 555 - (Programmers are used to the fallback exponent style “1.23E4”, but 556 that should not be shown to end-users. Instead, the exponential 557 notation superscriptingExponent should be used to show a format like 558 “1.23 × 10<sup>4</sup>”. ) The superscripting can use markup, such 559 as <sup>4</sup> in HTML, or for the special case of 560 Latin digits, use the superscript characters: U+207B ( ⁻ ), U+2070 ( 561 ⁰ ), U+00B9 ( ¹ ), U+00B2 ( ² ), U+00B3 ( ³ ), U+2074 ( ⁴ ) .. 562 U+2079 ( ⁹ ). 563 </dd> 564 <dt> 565 <b>perMille</b> 566 </dt> 567 <dd>- symbol used to indicate a per-mille (1/1000th) amount. (If 568 present, the value is also multiplied by 1000 before formatting. 569 That way 1.23 → 1230 [1/000])</dd> 570 <dt> 571 <b>infinity</b> 572 </dt> 573 <dd>- The infinity sign. Corresponds to the IEEE infinity bit 574 pattern.</dd> 575 <dt> 576 <b>nan - Not a number</b> 577 </dt> 578 <dd>- The NaN sign. Corresponds to the IEEE NaN bit pattern.</dd> 579 <dt> 580 <b>currencyDecimal</b> 581 </dt> 582 <dd>- Optional. If specified, then for currency formatting/parsing 583 this is used as the decimal separator instead of using the regular decimal 584 separator; otherwise, the regular decimal separator is used.</dd> 585 <dt> 586 <b>currencyGroup</b> 587 </dt> 588 <dd>- Optional. If specified, then for currency formatting/parsing 589 this is used as the group separator instead of using the regular group 590 separator; otherwise, the regular group separator is used.</dd> 591 <dt> 592 <b>timeSeparator</b> 593 </dt> 594 <dd> 595 - This replaces any use of the timeSeparator pattern character in a 596 date-time format pattern (no timeSeparator pattern character is 597 currently defined, see note below). This allows the same time format 598 to be used for multiple number systems when the time separator 599 depends on the number system. For example, the time format for 600 Arabic should be COLON when using the Latin numbering system (0, 1, 601 2, …), but when the Arabic numbering system is used (٠ - ١ - ٢ 602 …), the traditional time separator in older print styles was often 603 ARABIC COMMA. 604 <p class="note"> 605 <b>Note: </b>In CLDR 26 the timeSeparator pattern character was 606 specified to be COLON. This was withdrawn in CLDR 28 due to 607 backward compatibility issues, and no timeSeparator pattern 608 character is currently defined. No CLDR locales are known to have a 609 need to specify timeSeparator symbols that depend on number system; 610 if this changes in the future a different timeSeparator pattern 611 character will be defined. 612 </p> 613 </dd> 614 </dl> 615 <p>Example:</p> 616 <pre><symbols> 617 <decimal><span style="color: blue">.</span></decimal> 618 <group><span style="color: blue">,</span></group> 619 <list><span style="color: blue">;</span></list> 620 <percentSign><span style="color: blue">%</span></percentSign> 621 <patternDigit><span style="color: blue">#</span></patternDigit> 622 <plusSign><span style="color: blue">+</span></plusSign> 623 <minusSign><span style="color: blue">-</span></minusSign> 624 <exponential><span style="color: blue">E</span></exponential> 625 <superscriptingExponent><span style="color: blue">×</span></exponential> 626 <perMille><span style="color: blue">‰</span></perMille> 627 <infinity><span style="color: blue">∞</span></infinity> 628 <nan><span style="color: blue">☹</span></nan> 629 <timeSeparator>:</timeSeparator> 630</symbols></pre> 631 <p> 632 <span class="dtd"><!ATTLIST symbols numberSystem CDATA 633 #IMPLIED ><br> 634 </span> The numberSystem attribute is used to specify that the given number 635 symbols are to be used when the given numbering system is active. 636 Number symbols can only be defined for numbering systems of the 637 "numeric" type, since any special symbols required for an algorithmic 638 numbering system should be specified by the RBNF formatting rules 639 used for that numbering system. By default, number symbols without a 640 specific numberSystem attribute are assumed to be used for the 641 "latn" numbering system, which is western (ASCII) digits. 642 Locales that specify a numbering system other than "latn" 643 as the default should also specify number formatting symbols that are 644 appropriate for use within the context of the given numbering system. 645 For example, a locale that uses the Arabic-Indic digits as its 646 default would likely use an Arabic comma for the grouping separator 647 rather than the ASCII comma.<br> For more information on 648 numbering systems and their definitions, see <i><a 649 href="#Numbering_Systems">Section 1: Numbering Systems</a></i>. 650 </p> 651 652 <h3> 653 2.4 <a name="Number_Formats" href="#Number_Formats">Number 654 Formats</a> 655 </h3> 656 <p class="dtd"> 657 <!ELEMENT decimalFormats (alias | (default*, decimalFormatLength*, 658 special*))><br> <!ELEMENT decimalFormatLength (alias | 659 (default*, decimalFormat*, special*))><br> <!ATTLIST 660 decimalFormatLength type ( full | long | medium | short ) #IMPLIED 661 ><br> <!ELEMENT decimalFormat (alias | (pattern*, 662 special*)) ><br> 663 </p> 664 <p>(scientificFormats, percentFormats have the same structure)</p> 665 <p> 666 Number formats are used to define the rules for formatting numeric 667 quantities using the pattern syntax described in <i><a 668 href="#Number_Format_Patterns">Section 3: Number Format Patterns</a></i>. 669 </p> 670 <p>Different formats are provided for different contexts, as 671 follows:</p> 672 <dl> 673 <dt> </dt> 674 <dt> 675 <b>decimalFormats</b> 676 </dt> 677 <dd>The normal locale specific way to write a base 10 number. 678 Variations of the decimalFormat pattern are provided that allow 679 compact number formatting.</dd> 680 <dt> 681 <b>percentFormats</b> 682 </dt> 683 <dd>Pattern for use with percentage formatting</dd> 684 <dt> 685 <b>scientificFormats</b> 686 </dt> 687 <dd>Pattern for use with scientific (exponent) formatting.</dd> 688 </dl> 689 <p>Example:</p> 690 <pre><decimalFormats> 691 <decimalFormatLength type="<span style="color: blue">long</span>"> 692 <decimalFormat> 693 <pattern><span style="color: blue">#,##0.###</span></pattern> 694 </decimalFormat> 695 </decimalFormatLength> 696</decimalFormats></pre> 697 <pre><scientificFormats> 698 <default type="<span style="color: blue">long</span>"/> 699 <scientificFormatLength type="<span style="color: blue">long</span>"> 700 <scientificFormat> 701 <pattern><span style="color: blue">0.000###E+00</span></pattern> 702 </scientificFormat> 703 </scientificFormatLength> 704 <scientificFormatLength type="<span style="color: blue">medium</span>"> 705 <scientificFormat> 706 <pattern><span style="color: blue">0.00##E+00</span></pattern> 707 </scientificFormat> 708 </scientificFormatLength> 709</scientificFormats></pre> 710 <pre><percentFormats> 711 <percentFormatLength type="<span style="color: blue">long</span>"> 712 <percentFormat> 713 <pattern><span style="color: blue">#,##0%</span></pattern> 714 </percentFormat> 715 </percentFormatLength> 716</percentFormats></pre> 717 <p> 718 <span class="dtd"><!ATTLIST symbols numberSystem CDATA 719 #IMPLIED ><br> 720 </span> The numberSystem attribute is used to specify that the given number 721 formatting pattern(s) are to be used when the given numbering system 722 is active. By default, number formatting patterns without a specific 723 numberSystem attribute are assumed to be used for the 724 "latn" numbering system, which is western (ASCII) digits. 725 Locales that specify a numbering system other than "latn" 726 as the default should also specify number formatting patterns that 727 are appropriate for use within the context of the given numbering 728 system. <br> For more information on numbering systems and their 729 definitions, see <i><a href="#Numbering_Systems">Section 1: 730 Numbering Systems</a></i>. 731 </p> 732 <h4> 733 2.4.1 <a name="Compact_Number_Formats" href="#Compact_Number_Formats">Compact 734 Number Formats</a> 735 </h4> 736 A pattern type attribute is used for <em>compact number formats</em>, 737 such as the following: 738 <pre> 739<decimalFormatLength type="long"><br> <decimalFormat><br> <pattern type="1000" count="one">0 millier</pattern><br> <pattern type="1000" count="other">0 milliers</pattern><br> <pattern type="10000" count="one">00 mille</pattern><br> <pattern type="10000" count="other">00 mille</pattern><br> <pattern type="100000" count="one">000 mille</pattern><br> <pattern type="100000" count="other">000 mille</pattern><br> <pattern type="1000000" count="one">0 million</pattern><br> <pattern type="1000000" count="other">0 millions</pattern><br> …<br> </decimalFormat><br></decimalFormatLength><br><decimalFormatLength type="short"><br> <decimalFormat><br> <pattern type="1000" count="one">0 K</pattern><br> <pattern type="1000" count="other">0 K</pattern><br> <pattern type="10000" count="one">00 K</pattern><br> <pattern type="10000" count="other">00 K</pattern><br> <pattern type="100000" count="one">000 K</pattern><br> <pattern type="100000" count="other">000 K</pattern><br> <pattern type="1000000" count="one">0 M</pattern><br> <pattern type="1000000" count="other">0 M</pattern><br> …<br> </decimalFormat> 740… 741<currencyFormatLength type="short"><br> <currencyFormat type="standard"><br> <pattern type="1000" count="one">0 K ¤</pattern><br> <pattern type="1000" count="other">0 K ¤</pattern><br> <pattern type="10000" count="one">00 K ¤</pattern><br> <pattern type="10000" count="other">00 K ¤</pattern><br> <pattern type="100000" count="one">000 K ¤</pattern><br> <pattern type="100000" count="other">000 K ¤</pattern><br> <pattern type="1000000" count="one">0 M ¤</pattern><br> <pattern type="1000000" count="other">0 M ¤</pattern></pre> 742 <p>Formats can be supplied for numbers (as above) 743 or for currencies or other units. They can also be used with ranges 744 of numbers, resulting in formatting strings like “$10K” or “$3–7M”.</p> 745 <p>To format a number N, the greatest type less than or equal to N 746 is used, with the appropriate plural category. N is divided by the 747 type, after removing the number of zeros in the pattern, less 1. APIs 748 supporting this format should provide control over the number of 749 significant or fraction digits.</p> 750 <p>The 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.</p> 751 <p><code> <pattern type="1" count="one">0</pattern></code></p> 752 <p>If the value is precisely “0”, either explicit or defaulted, then the normal number format pattern for that sort 753 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 signficant 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. </p> 754 <p> 755 With the data above, N=12345 matches <code><pattern type="10000" 756 count="other">00 K</pattern></code> 757 . N is divided by 1000 (obtained from10000 after removing 758 "00" and restoring one "0". The result is 759 formatted according to the normal decimal pattern. With no fractional 760 digits, that yields "12 K". 761 </p> 762 <p>Formatting 1200 in USD would result in 763 “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 $”.</p> 764 <p>The short format is designed for UI environments where space is 765 at a premium, and should ideally result in a formatted string no more 766 than about 6 em wide (with no fractional digits).</p> 767 <h4> 768 2.4.2 <a name="Currency_Formats" href="#Currency_Formats">Currency 769 Formats</a> 770 </h4> 771 <p> 772 Pattern for use with currency formatting. This format contains a few 773 additional structural options that allow proper placement of the 774 currency symbol relative to the numeric quantity. Refer to <i><a 775 href="#Currencies">Section 4 - Currencies</a></i> for additional 776 information on the use of these options. 777 </p> 778 <p class="dtd"> 779 <!ELEMENT currencyFormats (alias | (default*, currencySpacing*, 780 currencyFormatLength*, unitPattern*, special*)) ><br> 781 <!ELEMENT currencySpacing (alias | (beforeCurrency*, 782 afterCurrency*, special*)) ><br> <!ELEMENT beforeCurrency 783 (alias | (currencyMatch*, surroundingMatch*, insertBetween*)) ><br> 784 <!ELEMENT afterCurrency (alias | (currencyMatch*, 785 surroundingMatch*, insertBetween*)) ><br> <!ELEMENT 786 currencyMatch ( #PCDATA ) ><br> <!ELEMENT surroundingMatch 787 ( #PCDATA )) ><br> <!ELEMENT insertBetween ( #PCDATA ) 788 ><br> <!ELEMENT currencyFormatLength (alias | (default*, 789 currencyFormat*, special*)) ><br> <!ATTLIST 790 currencyFormatLength type ( full | long | medium | short ) #IMPLIED 791 ><br> <!ELEMENT currencyFormat (alias | (pattern*, 792 special*)) > 793 </p> 794 <p>In addition to a standard currency format, in which negative 795 currency amounts might typically be displayed as something like 796 “-$3.27”, locales may provide an "accounting" form, in which for 797 "en_US" the same example would appear as “($3.27)”.</p> 798 <pre><currencyFormats> 799 <currencyFormatLength> 800 <currencyFormat type="standard"> 801 <pattern><span style="color: blue">¤#,##0.00</span></pattern> 802 </currencyFormat> 803 <currencyFormat type="accounting"> 804 <pattern><span style="color: blue">¤#,##0.00;(¤#,##0.00)</span></pattern> 805 </currencyFormat> 806 </currencyFormatLength> 807</currencyFormats></pre> 808 809 <h3> 810 2.5 <a name="Miscellaneous_Patterns" href="#Miscellaneous_Patterns">Miscellaneous 811 Patterns</a> 812 </h3> 813 <p class="dtd"> 814 <!ELEMENT miscPatterns (alias | (default*, pattern*, special*)) 815 ><br> <!ATTLIST miscPatterns numberSystem CDATA #IMPLIED 816 > 817 </p> 818 <p>The miscPatterns supply additional patterns for special 819 purposes. The currently defined values are:</p> 820 <dl> 821 <dt><strong>approximately</strong> </dt> 822 <dd>indicates an approximate number, such as: “~99”</dd> 823 <dt><strong>atMost</strong> </dt> 824 <dd>indicates a number or lower, such as: “<code>≤</code>99” to indicate 825 that there are 99 items or fewer.</dd> 826 <dt><strong>atLeast</strong> </dt> 827 <dd>indicates a number or higher, such as: “99+” to indicate 828 that there are 99 items or more.</dd> 829 <dt><strong>range</strong></dt> 830 <dd>indicates a range of numbers, such as: “99–103” to indicate 831 that there are from 99 to 103 items.</dd> 832 </dl> 833 <p> 834 <em>For example: </em> 835 </p> 836 <p> 837 <code> 838 <miscPatterns numberSystem="…"><br> 839 <pattern type="approximately">~{0}</pattern><br> 840 <pattern type="atLeast">≥{0}</pattern> <br> 841 <pattern type="atMost">≤{0}</pattern><br> 842 843 <pattern type="range">{0}–{1}</pattern> <br> 844 </miscPatterns></code> 845 </p> 846 <h3> 847 2.6 <a name="Minimal_Pairs" href="#Minimal_Pairs">Minimal Pairs</a></h3> 848 <p class="dtd"><!ELEMENT minimalPairs ( alias | ( pluralMinimalPairs*, ordinalMinimalPairs*, special* ) ) > 849 <br><!ATTLIST minimalPairs alt NMTOKENS #IMPLIED > <br> 850 <!ATTLIST minimalPairs draft (approved | contributed | provisional | unconfirmed) #IMPLIED > <br> 851 </p> 852 <p class="dtd"><!ELEMENT pluralMinimalPairs ( #PCDATA ) > <br> 853 <!ATTLIST pluralMinimalPairs count NMTOKEN #IMPLIED > <br> 854 <!ATTLIST pluralMinimalPairs alt NMTOKENS #IMPLIED > <br> 855 <!ATTLIST pluralMinimalPairs draft (approved | contributed | provisional | unconfirmed) #IMPLIED ></p> 856 <p class="dtd"><!ELEMENT ordinalMinimalPairs ( #PCDATA ) > <br> 857 <!ATTLIST ordinalMinimalPairs ordinal NMTOKEN #IMPLIED > <br> 858 <!ATTLIST ordinalMinimalPairs alt NMTOKENS #IMPLIED > <br> 859 <!ATTLIST ordinalMinimalPairs draft (approved | contributed | provisional | unconfirmed) #IMPLIED ></p> 860 <p>Minimal pairs provide examples that justify why multiple plural or ordinal categories exist. For more information, see <a href="http://cldr.unicode.org/index/cldr-spec/plural-rules">Plural Rules</a>.</p> 861 <h2> 862 <a name="Number_Format_Patterns" href="#Number_Format_Patterns">3 863 Number Format Patterns</a> 864 </h2> 865 <h3> 866 3.1 <a name="Number_Patterns" href="#Number_Patterns">Number 867 Patterns</a> 868 </h3> 869 <p>Number patterns affect how numbers are interpreted in a 870 localized context. Here are some examples, based on the French 871 locale. The "." shows where the decimal point should go. 872 The "," shows where the thousands separator should go. A 873 "0" indicates zero-padding: if the number is too short, a 874 zero (in the locale's numeric set) will go there. A "#" 875 indicates no padding: if the number is too short, nothing goes there. 876 A "¤" shows where the currency sign will go. The following 877 illustrates the effects of different patterns for the French locale, 878 with the number "1234.567". Notice how the pattern 879 characters ',' and '.' are replaced by the characters 880 appropriate for the locale.</p> 881 <blockquote> 882 <table cellspacing="0" cellpadding="4" border="1"> 883 <caption> 884 <a name="Number_Pattern_Examples" href="#Number_Pattern_Examples">Number 885 Pattern Examples</a> 886 </caption> 887 <tr bgcolor="#ccccff"> 888 <th width="17%">Pattern</th> 889 <th width="16%">Currency</th> 890 <th width="33%">Text</th> 891 </tr> 892 <tr> 893 <td width="17%">#,##0.##</td> 894 <td width="16%"><i>n/a</i></td> 895 <td width="33%">1 234,57</td> 896 </tr> 897 <tr> 898 <td width="17%">#,##0.###</td> 899 <td width="16%"><i>n/a</i></td> 900 <td width="33%">1 234,567</td> 901 </tr> 902 <tr> 903 <td width="17%">###0.#####</td> 904 <td width="16%"><i>n/a</i></td> 905 <td width="33%">1234,567</td> 906 </tr> 907 <tr> 908 <td width="17%">###0.0000#</td> 909 <td width="16%"><i>n/a</i></td> 910 <td width="33%">1234,5670</td> 911 </tr> 912 <tr> 913 <td width="17%">00000.0000</td> 914 <td width="16%"><i>n/a</i></td> 915 <td width="33%">01234,5670</td> 916 </tr> 917 <tr> 918 <td width="17%" rowspan="2">#,##0.00 ¤</td> 919 <td width="16%">EUR</td> 920 <td width="33%">1 234,57 €</td> 921 </tr> 922 <tr> 923 <td width="16%">JPY</td> 924 <td width="33%">1 235 ¥JP</td> 925 </tr> 926 </table> 927 </blockquote> 928 <p> 929 The number of # placeholder characters before the decimal do not 930 matter, since no limit is placed on the maximum number of digits. 931 There should, however, be at least one zero someplace in the pattern. 932 In currency formats, the number of digits after the decimal also do 933 not matter, since the information in the supplemental data (see <i><a 934 href="#Supplemental_Currency_Data">Supplemental Currency Data</a>)</i> 935 is used to override the number of decimal places — and the rounding — 936 according to the currency that is being formatted. That can be seen 937 in the above chart, with the difference between Yen and Euro 938 formatting. 939 </p> 940 <p> 941 To ensure correct layout, especially in currency patterns in which a 942 a variety of symbols may be used, number patterns may contain (invisible) 943 bidirectional text format characters such as LRM, RLM, and ALM. 944 </p> 945 <p> 946 <i>When parsing using a pattern, a lenient parse should be used; 947 see <a href="tr35.html#Lenient_Parsing">Lenient Parsing</a>.</i> As noted there, lenient parsing should ignore bidi format 948 characters. 949 </p> 950 <h3> 951 3.2 <a name="Special_Pattern_Characters" 952 href="#Special_Pattern_Characters">Special Pattern Characters</a> 953 </h3> 954 <p>Many characters in a pattern are taken literally; they are 955 matched during parsing and output unchanged during formatting. 956 Special characters, on the other hand, stand for other characters, 957 strings, or classes of characters. For example, the '#' 958 character is replaced by a localized digit for the chosen 959 numberSystem. Often the replacement character is the same as the 960 pattern character; in the U.S. locale, the ',' grouping 961 character is replaced by ','. However, the replacement is 962 still happening, and if the symbols are modified, the grouping 963 character changes. Some special characters affect the behavior of the 964 formatter by their presence; for example, if the percent character is 965 seen, then the value is multiplied by 100 before being displayed.</p> 966 <p> 967 To insert a special character in a pattern as a literal, that is, 968 without any special meaning, the character must be quoted. There are 969 some exceptions to this which are noted below. The Localized 970 Replacement column shows the replacement from <em>Section 2.3 <a 971 href="#Number_Symbols">Number Symbols</a> 972 </em> or the numberSystem's digits: <em>italic</em> indicates a special 973 function. 974 </p> 975 <p> 976 Invalid sequences of special characters (such as “¤¤¤¤¤” in current 977 CLDR) should be handled for formatting and parsing as described in <a 978 href="tr35.html#Invalid_Patterns">Handling Invalid Patterns</a>. 979 </p> 980 <blockquote> 981 <table cellspacing="3" cellpadding="0" 982 summary="Chart showing symbol, 983 location, localized, and meaning." 984 border="0"> 985 <caption> 986 <a name="Number_Pattern_Character_Definitions" 987 href="#Number_Pattern_Character_Definitions">Number Pattern 988 Character Definitions</a> 989 </caption> 990 <tr bgcolor="#ccccff"> 991 <th align="left">Symbol</th> 992 <th align="left">Location</th> 993 <th align="left">Localized Replacement</th> 994 <th colspan="2" align="left">Meaning</th> 995 </tr> 996 <tr valign="top"> 997 <td>0</td> 998 <td>Number</td> 999 <td>digit</td> 1000 <td colspan="2">Digit</td> 1001 </tr> 1002 <tr valign="top" bgcolor="#eeeeff"> 1003 <td>1-9</td> 1004 <td>Number</td> 1005 <td>digit</td> 1006 <td colspan="2">'1' through '9' indicate 1007 rounding.</td> 1008 </tr> 1009 <tr valign="top"> 1010 <td>@</td> 1011 <td>Number</td> 1012 <td>digit</td> 1013 <td colspan="2">Significant digit</td> 1014 </tr> 1015 <tr valign="top" bgcolor="#eeeeff"> 1016 <td>#</td> 1017 <td>Number</td> 1018 <td>digit, <em>nothing</em></td> 1019 <td colspan="2">Digit, omitting leading/trailing zeros</td> 1020 </tr> 1021 <tr valign="top"> 1022 <td>.</td> 1023 <td>Number</td> 1024 <td>decimal, currencyDecimal</td> 1025 <td colspan="2">Decimal separator or monetary decimal 1026 separator</td> 1027 </tr> 1028 <tr valign="top" bgcolor="#eeeeff"> 1029 <td>-</td> 1030 <td>Number</td> 1031 <td>minusSign</td> 1032 <td colspan="2">Minus sign. <strong>Warning: </strong>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 Section 3.2.1 <a href="#Explicit_Plus">Explicit Plus Signs</a>.</td> 1033 </tr> 1034 <tr valign="top"> 1035 <td>,</td> 1036 <td>Number</td> 1037 <td>group, currencyGroup</td> 1038 <td colspan="2">Grouping separator. May occur in both the 1039 integer part and the fractional part. The position determines the 1040 grouping.</td> 1041 </tr> 1042 <tr valign="top" bgcolor="#eeeeff"> 1043 <td>E</td> 1044 <td>Number</td> 1045 <td>exponential, superscriptingExponent</td> 1046 <td colspan="2">Separates mantissa and exponent in scientific 1047 notation. <em>Need not be quoted in prefix or suffix.</em> 1048 </td> 1049 </tr> 1050 <tr valign="top"> 1051 <td>+</td> 1052 <td>Exponent or Number (for 1053 explicit plus)</td> 1054 <td>plusSign</td> 1055 <td colspan="2">Prefix positive exponents with localized plus 1056 sign. Used for explicit plus for numbers as well, as described in 1057 Section 3.2.1 <a href="#Explicit_Plus">Explicit Plus Signs</a>. <em><br> 1058 Need not be quoted in prefix or suffix.</em> 1059 </td> 1060 </tr> 1061 <tr valign="top"> 1062 <td>%</td> 1063 <td>Prefix or suffix</td> 1064 <td>percentSign</td> 1065 <td colspan="2">Multiply by 100 and show as percentage</td> 1066 </tr> 1067 <tr valign="top" bgcolor="#eeeeff"> 1068 <td>‰<br> (U+2030) 1069 </td> 1070 <td>Prefix or suffix</td> 1071 <td>perMille</td> 1072 <td colspan="2">Multiply by 1000 and show as per mille (aka 1073 “basis points”)</td> 1074 </tr> 1075 <tr valign="top" bgcolor="#eeeeff"> 1076 <td>;</td> 1077 <td>Subpattern boundary</td> 1078 <td><em>syntax</em></td> 1079 <td colspan="2">Separates positive and negative subpatterns. 1080 When there is no explicit negative subpattern, an implicit 1081 negative subpattern is formed from the positive pattern with a 1082 prefixed - (ASCII U+002D HYPHEN-MINUS).</td> 1083 </tr> 1084 <tr valign="top"> 1085 <td rowspan="11">¤ (U+00A4)</td> 1086 <td rowspan="11">Prefix or suffix</td> 1087 <td rowspan="11"><em>currency symbol/name from currency 1088 specified in API</em></td> 1089 <td colspan="2">Any sequence is replaced by the localized 1090 currency symbol for the currency being formatted, as in the table 1091 below. If present in a pattern, the monetary decimal separator and 1092 grouping separators (if available) are used instead of the numeric 1093 ones. If data is unavailable for a given sequence in a given 1094 locale, the display may fall back to ¤ or ¤¤. See also the 1095 formatting forcurrency display names, steps 2 and 4 in <a 1096 href="#Currencies">Currencies</a>. 1097 </td> 1098 </tr> 1099 <tr valign="top"> 1100 <th>No.</th> 1101 <th>Replacement / Example</th> 1102 </tr> 1103 <tr valign="top"> 1104 <td rowspan="2">¤</td> 1105 <td>Standard currency symbol</td> 1106 </tr> 1107 <tr valign="top"> 1108 <td><em>C$12.00</em></td> 1109 </tr> 1110 <tr valign="top"> 1111 <td rowspan="2">¤¤</td> 1112 <td>ISO currency symbol (constant)</td> 1113 </tr> 1114 <tr valign="top"> 1115 <td><em>CAD 12.00</em></td> 1116 </tr> 1117 <tr valign="top"> 1118 <td rowspan="2">¤¤¤</td> 1119 <td>Appropriate currency display name for the currency, based 1120 on the plural rules in effect for the locale</td> 1121 </tr> 1122 <tr valign="top"> 1123 <td><em>5.00 Canadian dollars</em></td> 1124 </tr> 1125 <tr valign="top"> 1126 <td rowspan="2" nowrap>¤¤¤¤¤</td> 1127 <td>Narrow currency symbol. The same symbols may be used for 1128 multiple currencies. Thus the symbol may be ambiguous, and should 1129 only be used where the context is clear.</td> 1130 </tr> 1131 <tr valign="top"> 1132 <td><em>$12.00</em></td> 1133 </tr> 1134 <tr valign="top"> 1135 <td><em>others</em></td> 1136 <td><em>Invalid in current 1137 CLDR. Reserved for future specification</em></td> 1138 </tr> 1139 <tr valign="top"> 1140 <td>*</td> 1141 <td>Prefix or suffix boundary</td> 1142 <td><em>padding character specified in API</em></td> 1143 <td colspan="2">Pad escape, precedes pad character</td> 1144 </tr> 1145 <tr valign="top" bgcolor="#eeeeff"> 1146 <td>'</td> 1147 <td>Prefix or suffix</td> 1148 <td><em>syntax-only</em></td> 1149 <td colspan="2">Used to quote special characters in a prefix 1150 or suffix, for example, <code>"'#'#"</code> 1151 formats 123 to <code>"#123"</code>. To create a single 1152 quote itself, use two in a row: <code>"# 1153 o''clock"</code>. 1154 </td> 1155 </tr> 1156 </table> 1157 </blockquote> 1158 <p>A pattern contains a positive subpattern and may contain a 1159 negative subpattern, for example, "#,##0.00;(#,##0.00)". 1160 Each subpattern has a prefix, a numeric part, and a suffix. If there 1161 is no explicit negative subpattern, the implicit negative subpattern 1162 is the ASCII minus sign (-) prefixed to the positive subpattern. That 1163 is, "0.00" alone is equivalent to "0.00;-0.00". 1164 (The data in CLDR is normalized to remove an explicit negative subpattern 1165 where it would be identical to the implicit form.)</p> 1166 <p> Note that if an negative subpattern is used as-is: a minus sign is <em>not</em> 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".</p> 1167 <p>If there is an 1168 explicit negative subpattern, it serves only to specify the negative 1169 prefix and suffix; the number of digits, minimal digits, and other 1170 characteristics are ignored in the negative subpattern. That means 1171 that "#,##0.0#;(#)" has precisely the same result as 1172 "#,##0.0#;(#,##0.0#)". However in the CLDR data, the format 1173 is normalized so that the other characteristics are preserved, just 1174 for readability. </p> 1175 <blockquote> 1176 <p> 1177 <b>Note: </b>The thousands separator and decimal separator in 1178 patterns are always ASCII ',' and '.'. They are 1179 substituted by the code with the correct local values according to 1180 other fields in CLDR. The same is true of the - (ASCII minus sign) 1181 and other special characters listed above. 1182 </p> 1183 </blockquote> 1184 <p>Below is a sample of patterns, special characters, and results:</p> 1185 <div align="center"> 1186 <table border="0" cellpadding="0" cellspacing="3"> 1187 <caption> 1188 <a name='Sample_Patterns_and_Results' 1189 href='#Sample_Patterns_and_Results'>Sample Patterns and 1190 Results</a> 1191 </caption> 1192 <tr valign="top"> 1193 <th><div align="right">explicit pattern:</div></th> 1194 <td colspan="2"><div align="center">0.00;-0.00</div></td> 1195 <td colspan="2"><div align="center">0.00;0.00-</div></td> 1196 <td colspan="2"><div align="center">0.00+;0.00-</div></td> 1197 </tr> 1198 <tr valign="top"> 1199 <th><div align="right">decimalSign:</div></th> 1200 <td colspan="2"><div align="center">,</div></td> 1201 <td colspan="2"><div align="center">,</div></td> 1202 <td colspan="2"><div align="center">,</div></td> 1203 </tr> 1204 <tr valign="top"> 1205 <th><div align="right">minusSign:</div></th> 1206 <td colspan="2"><div align="center">∸</div></td> 1207 <td colspan="2"><div align="center">∸</div></td> 1208 <td colspan="2"><div align="center">∸</div></td> 1209 </tr> 1210 <tr valign="top"> 1211 <th><div align="right">plusSign:</div></th> 1212 <td colspan="2"><div align="center">∔</div></td> 1213 <td colspan="2"><div align="center">∔</div></td> 1214 <td colspan="2"><div align="center">∔</div></td> 1215 </tr> 1216 <tr valign="top"> 1217 <th><div align="right">number:</div></th> 1218 <td><div align="center">3.1415</div></td> 1219 <td><div align="center">-3.1415</div></td> 1220 <td><div align="center">3.1415</div></td> 1221 <td><div align="center">-3.1415</div></td> 1222 <td><div align="center">3.1415</div></td> 1223 <td><div align="center">-3.1415</div></td> 1224 </tr> 1225 <tr valign="top"> 1226 <th><div align="right">formatted:</div></th> 1227 <td><div align="center">3,14</div></td> 1228 <td><div align="center">∸3,14</div></td> 1229 <td><div align="center">3,14</div></td> 1230 <td><div align="center">3,14∸</div></td> 1231 <td><div align="center">3,14∔</div></td> 1232 <td><div align="center">3,14∸</div></td> 1233 </tr> 1234 </table> 1235 <p> 1236 <em>In the above table, ∸ = U+2238 DOT MINUS and ∔ = U+2214 DOT 1237 PLUS are used for illustration.</em> 1238 </p> 1239 </div> 1240 <p> 1241 The prefixes, suffixes, and various symbols used for infinity, 1242 digits, thousands separators, decimal separators, and so on may be 1243 set to arbitrary values, and they will appear properly during 1244 formatting. <i>However, care must be taken that the symbols and 1245 strings do not conflict, or parsing will be unreliable. </i> For 1246 example, either the positive and negative prefixes or the suffixes 1247 must be distinct for any parser using this data to be able to 1248 distinguish positive from negative values. Another example is that 1249 the decimal separator and thousands separator should be distinct 1250 characters, or parsing will be impossible. 1251 </p> 1252 <p> 1253 The <em>grouping separator</em> is a character that separates 1254 clusters of integer digits to make large numbers more legible. It is 1255 commonly used for thousands, but in some locales it separates 1256 ten-thousands. The <em>grouping size</em> is the number of digits 1257 between the grouping separators, such as 3 for 1258 "100,000,000" or 4 for "1 0000 0000". There are 1259 actually two different grouping sizes: One used for the least 1260 significant integer digits, the <em>primary grouping size</em>, and 1261 one used for all others, the <em>secondary grouping size</em>. In 1262 most locales these are the same, but sometimes they are different. 1263 For example, if the primary grouping interval is 3, and the secondary 1264 is 2, then this corresponds to the pattern "#,##,##0", and 1265 the number 123456789 is formatted as "12,34,56,789". If a 1266 pattern contains multiple grouping separators, the interval between 1267 the last one and the end of the integer defines the primary grouping 1268 size, and the interval between the last two defines the secondary 1269 grouping size. All others are ignored, so "#,##,###,####" 1270 == "###,###,####" == "##,#,###,####". 1271 </p> 1272 <p> 1273 The grouping separator may also occur in the fractional part, such as 1274 in “#,##0.###,#”. This is most commonly done where the grouping 1275 separator character is a thin, non-breaking space (U+202F), such as 1276 “1.618 033 988 75”. See <a 1277 href="http://physics.nist.gov/cuu/Units/checklist.html ">physics.nist.gov/cuu/Units/checklist.html</a>. 1278 </p> 1279 1280 <p>For consistency in the CLDR data, the following conventions are 1281 observed:</p> 1282 <ul> 1283 <li>All number patterns should be minimal: there should be no 1284 leading # marks except to specify the position of the grouping 1285 separators (for example, avoid ##,##0.###).</li> 1286 <li>All formats should have one 0 before the decimal point (for 1287 example, avoid #,###.##)</li> 1288 <li>Decimal formats should have three hash marks in the 1289 fractional position (for example, #,##0.###).</li> 1290 <li>Currency formats should have two zeros in the fractional 1291 position (for example, ¤ #,##0.00). 1292 <ul> 1293 <li>The exact number of decimals is overridden with the 1294 decimal count in supplementary data or by API settings.</li> 1295 </ul> 1296 </li> 1297 <li>The only time two thousands separators needs to be used is 1298 when the number of digits varies, such as for Hindi: #,##,##0.</li> 1299 <li>The <strong>minimumGroupingDigits</strong> can be used to 1300 suppress groupings below a certain value. This is used for languages 1301 such as Polish, where one would only write the grouping separator 1302 for values above 9999. The minimumGroupingDigits contains the 1303 default for the locale. 1304 <ul> 1305 <li>The attribute value is used by adding it to the grouping 1306 separator value. If the input number has fewer integer digits, the 1307 grouping separator is suppressed.</li> 1308 <li> 1309 <table border="1" cellpadding="0" cellspacing="0"> 1310 <caption> 1311 <a name="Examples_of_minimumGroupingDigits" 1312 href="#Examples_of_minimumGroupingDigits">Examples of 1313 minimumGroupingDigits</a> 1314 </caption> 1315 <tr> 1316 <th width="25%" scope="col"><div align="center">minimum­GroupingDigits</div></th> 1317 <th width="25%" scope="col"><div align="center">Pattern 1318 Grouping</div></th> 1319 <th width="25%" scope="col"><div align="center">Input 1320 Number</div></th> 1321 <th width="25%" scope="col"><div align="center">Formatted</div></th> 1322 </tr> 1323 <tr> 1324 <td><div align="right">1</div></td> 1325 <td><div align="right">3</div></td> 1326 <td><div align="right">1000</div></td> 1327 <td><div align="right">1,000</div></td> 1328 </tr> 1329 <tr> 1330 <td><div align="right">1</div></td> 1331 <td><div align="right">3</div></td> 1332 <td><div align="right">10000</div></td> 1333 <td><div align="right">10,000</div></td> 1334 </tr> 1335 <tr> 1336 <td><div align="right">2</div></td> 1337 <td><div align="right">3</div></td> 1338 <td><div align="right">1000</div></td> 1339 <td><div align="right">1000</div></td> 1340 </tr> 1341 <tr> 1342 <td><div align="right">2</div></td> 1343 <td><div align="right">3</div></td> 1344 <td><div align="right">10000</div></td> 1345 <td><div align="right">10,000</div></td> 1346 </tr> 1347 <tr> 1348 <td><div align="right">1</div></td> 1349 <td><div align="right">4</div></td> 1350 <td><div align="right">10000</div></td> 1351 <td><div align="right">1,0000</div></td> 1352 </tr> 1353 <tr> 1354 <td><div align="right">2</div></td> 1355 <td><div align="right">4</div></td> 1356 <td><div align="right">10000</div></td> 1357 <td><div align="right">10000</div></td> 1358 </tr> 1359 </table></li> 1360 </ul> 1361 </li> 1362 </ul> 1363 <h4> 1364 3.2.1 <a name="Explicit_Plus" href="#Explicit_Plus">Explicit Plus 1365 Signs</a> 1366 </h4> 1367 <p> 1368 An explicit "plus" format can be formed, so as to show a 1369 visible + sign when formatting a non-negative number. The displayed 1370 plus sign can be an ASCII plus or another character, such as + U+FF0B 1371 FULLWIDTH PLUS SIGN or ➕ U+2795 HEAVY PLUS SIGN; it is taken from 1372 whatever is set for plusSign in <em>Section 2.3 <a 1373 href="#Number_Symbols">Number Symbols</a></em>. 1374 </p> 1375 <ol> 1376 <li>Get the negative subpattern (explicit or implicit).</li> 1377 <li>Replace any unquoted ASCII minus sign by an ASCII plus sign.</li> 1378 <li>If there are any replacements, use that for the positive 1379 subpattern.</li> 1380 </ol> 1381 <p> 1382 For an example, see <a href="#Sample_Patterns_and_Results">Sample 1383 Patterns and Results</a>. 1384 </p> 1385 <h3> 1386 3.3 <a name="Formatting" href="#Formatting">Formatting</a> 1387 </h3> 1388 <p> 1389 Formatting is guided by several parameters, all of which can be 1390 specified either using a pattern or using an external API designed 1391 for number formatting. The following description applies to formats 1392 that do not use <a href="#sci">scientific notation</a> or <a 1393 href="#sigdig">significant digits</a>. 1394 </p> 1395 <ul> 1396 <li>If the number of actual integer digits exceeds the <em>maximum 1397 integer digits</em>, then only the least significant digits are shown. 1398 For example, 1997 is formatted as "97" if the maximum 1399 integer digits is set to 2. 1400 </li> 1401 <li>If the number of actual integer digits is less than the <em>minimum 1402 integer digits</em>, then leading zeros are added. For example, 1997 is 1403 formatted as "01997" if the minimum integer digits is set 1404 to 5. 1405 </li> 1406 <li>If the number of actual fraction digits exceeds the <em>maximum 1407 fraction digits</em>, then half-even rounding it performed to the 1408 maximum fraction digits. For example, 0.125 is formatted as 1409 "0.12" if the maximum fraction digits is 2. This behavior 1410 can be changed by specifying a rounding increment and a rounding 1411 mode. 1412 </li> 1413 <li>If the number of actual fraction digits is less than the <em>minimum 1414 fraction digits</em>, then trailing zeros are added. For example, 0.125 1415 is formatted as "0.1250" if the minimum fraction digits is 1416 set to 4. 1417 </li> 1418 <li>Trailing fractional zeros are not displayed if they occur <em>j</em> 1419 positions after the decimal, where <em>j</em> is less than the 1420 maximum fraction digits. For example, 0.10004 is formatted as 1421 "0.1" if the maximum fraction digits is four or less. 1422 </li> 1423 </ul> 1424 <p> 1425 <strong>Special Values</strong> 1426 </p> 1427 <p> 1428 <code>NaN</code> 1429 is represented as a single character, typically 1430 <code> (U+FFFD) </code> 1431 . This character is determined by the localized number symbols. This 1432 is the only value for which the prefixes and suffixes are not used. 1433 </p> 1434 <p> 1435 Infinity is represented as a single character, typically <font 1436 size="3">∞ </font> 1437 <code> (U+221E) </code> 1438 , with the positive or negative prefixes and suffixes applied. The 1439 infinity character is determined by the localized number symbols. 1440 </p> 1441 <h3> 1442 3.4 <a name="sci" href="#sci">Scientific Notation</a> 1443 </h3> 1444 <p> 1445 Numbers in scientific notation are expressed as the product of a 1446 mantissa and a power of ten, for example, 1234 can be expressed as 1447 1.234 x 10<sup>3</sup>. The mantissa is typically in the half-open 1448 interval [1.0, 10.0) or sometimes [0.0, 1.0), but it need not be. In 1449 a pattern, the exponent character immediately followed by one or more 1450 digit characters indicates scientific notation. Example: 1451 "0.###E0" formats the number 1234 as "1.234E3". 1452 </p> 1453 <ul> 1454 <li>The number of digit characters after the exponent character 1455 gives the minimum exponent digit count. There is no maximum. 1456 Negative exponents are formatted using the localized minus sign, <em>not</em> 1457 the prefix and suffix from the pattern. This allows patterns such as 1458 "0.###E0 m/s". To prefix positive exponents with a 1459 localized plus sign, specify '+' between the exponent and 1460 the digits: "0.###E+0" will produce formats 1461 "1E+1", "1E+0", "1E-1", and so on. (In 1462 localized patterns, use the localized plus sign rather than 1463 '+'.) 1464 </li> 1465 <li>The minimum number of integer digits is achieved by 1466 adjusting the exponent. Example: 0.00123 formatted with 1467 "00.###E0" yields "12.3E-4". This only happens 1468 if there is no maximum number of integer digits. If there is a 1469 maximum, then the minimum number of integer digits is fixed at one.</li> 1470 <li>The maximum number of integer digits, if present, specifies 1471 the exponent grouping. The most common use of this is to generate <em>engineering 1472 notation</em>, in which the exponent is a multiple of three, for 1473 example, "##0.###E0". The number 12345 is formatted using 1474 "##0.####E0" as "12.345E3". </li> 1475 <li> 1476 <p>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:<br> 1477 </p> 1478 <ol> 1479 <li>If the mantissa pattern contains a period: 1480 <ol> 1481 <li>If the mantissa pattern contains at least one 0: 1482 <ul> 1483 <li>Return the number of 0s before the period added to the number of #s or 0s after the period</li> 1484 </ul> 1485 </li> 1486 <li>Else: 1487 <ul> 1488 <li>Return 1 plus the number of #s after the period</li> 1489 </ul> 1490 </li> 1491 </ol> 1492 </li> 1493 <li>Else: 1494 <ol> 1495 <li>If the mantissa pattern contains at least one 0: 1496 <ul> 1497 <li>Return the number of 0s.</li> 1498 </ul> 1499 </li> 1500 <li>Else: 1501 <ul> 1502 <li>Return positive infinity.</li> 1503 </ul> 1504 </li> 1505 </ol> 1506 </li> 1507 </ol> 1508 <p>Examples:<br> 1509 </p> 1510 <ul> 1511 <li>0.##E0 means a max of 3 significant digits.</li> 1512 <li>#.##E0 also means a max of 3 significant digits.</li> 1513 <li>#.0#E0 means a max of 2 significant digits.</li> 1514 <li>0E0 means a max of 1 significant digit.</li> 1515 <li>#E0 means infinite precision.</li> 1516 <li>###E0 means engineering notation with infinite precision. </li> 1517 </ul> 1518 </li> 1519 <li>Exponential patterns may not contain grouping separators.</li> 1520 </ul> 1521 <h3> 1522 3.5 <a name="sigdig" href="#sigdig">Significant Digits</a> 1523 </h3> 1524 <p>There are two ways of controlling how many digits are shows: 1525 (a) significant digits counts, or (b) integer and fraction digit 1526 counts. Integer and fraction digit counts are described above. When a 1527 formatter is using significant digits counts, it uses however many 1528 integer and fraction digits are required to display the specified 1529 number of significant digits. It may ignore min/max integer/fraction 1530 digits, or it may use them to the extent possible.</p> 1531 1532 <blockquote> 1533 <table cellpadding="0" border="0"> 1534 <caption> 1535 <a name="Significant_Digits_Examples" 1536 href="#Significant_Digits_Examples">Significant Digits 1537 Examples</a> 1538 </caption> 1539 <tr bgcolor="#ccccff"> 1540 <th align="left">Pattern</th> 1541 <th align="left">Minimum significant digits</th> 1542 <th align="left">Maximum significant digits</th> 1543 <th align="left">Number</th> 1544 <th align="left">Output</th> 1545 </tr> 1546 <tr valign="top"> 1547 <td><code>@@@</code></td> 1548 <td>3</td> 1549 <td>3</td> 1550 <td>12345</td> 1551 <td><code>12300</code></td> 1552 </tr> 1553 <tr valign="top" bgcolor="#eeeeff"> 1554 <td><code>@@@</code></td> 1555 <td>3</td> 1556 <td>3</td> 1557 <td>0.12345</td> 1558 <td><code>0.123</code></td> 1559 </tr> 1560 <tr valign="top"> 1561 <td><code>@@##</code></td> 1562 <td>2</td> 1563 <td>4</td> 1564 <td>3.14159</td> 1565 <td><code>3.142</code></td> 1566 </tr> 1567 <tr valign="top" bgcolor="#eeeeff"> 1568 <td><code>@@##</code></td> 1569 <td>2</td> 1570 <td>4</td> 1571 <td>1.23004</td> 1572 <td><code>1.23</code></td> 1573 </tr> 1574 </table> 1575 </blockquote> 1576 <ul> 1577 <li>In order to enable significant digits formatting, use a 1578 pattern containing the <code>'@'</code> pattern character. 1579 In order to disable significant digits formatting, use a pattern 1580 that does not contain the <code>'@'</code> pattern 1581 character. 1582 </li> 1583 <li>Significant digit counts may be expressed using patterns 1584 that specify a minimum and maximum number of significant digits. 1585 These are indicated by the <code>'@'</code> and <code>'#'</code> 1586 characters. The minimum number of significant digits is the number 1587 of <code>'@'</code> characters. The maximum number of 1588 significant digits is the number of <code>'@'</code> 1589 characters plus the number of <code>'#'</code> characters 1590 following on the right. For example, the pattern <code>"@@@"</code> 1591 indicates exactly 3 significant digits. The pattern <code>"@##"</code> 1592 indicates from 1 to 3 significant digits. Trailing zero digits to 1593 the right of the decimal separator are suppressed after the minimum 1594 number of significant digits have been shown. For example, the 1595 pattern <code>"@##"</code> formats the number 0.1203 as <code>"0.12"</code>. 1596 </li> 1597 <li>Implementations may forbid the use of significant digits in 1598 combination with min/max integer/fraction digits. In such a case, if 1599 a pattern uses significant digits, it may not contain a decimal 1600 separator, nor the <code>'0'</code> pattern character. 1601 Patterns such as <code>"@00"</code> or <code>"@.###"</code> 1602 would be disallowed. 1603 </li> 1604 <li>Any number of <code>'#'</code> characters may be 1605 prepended to the left of the leftmost <code>'@'</code> 1606 character. These have no effect on the minimum and maximum 1607 significant digits counts, but may be used to position grouping 1608 separators. For example, <code>"#,#@#"</code> indicates a 1609 minimum of one significant digits, a maximum of two significant 1610 digits, and a grouping size of three. 1611 </li> 1612 <li>The number of significant digits has no effect on parsing.</li> 1613 <li>Significant digits may be used together with exponential 1614 notation. Such patterns are equivalent to a normal exponential 1615 pattern with a minimum and maximum integer digit count of one, a 1616 minimum fraction digit count of <code>Minimum Significant 1617 Digits - 1</code>, and a maximum fraction digit count of <code>Maximum 1618 Significant Digits - 1</code>. For example, the pattern <code>"@@###E0"</code> 1619 is equivalent to <code>"0.0###E0"</code>. 1620 </li> 1621 </ul> 1622 <h3> 1623 3.6 <a name="Padding" href="#Padding">Padding</a> 1624 </h3> 1625 <p> 1626 Patterns support padding the result to a specific width. In a pattern 1627 the pad escape character, followed by a single pad character, causes 1628 padding to be parsed and formatted. The pad escape character is 1629 '*'. For example, 1630 <code>"$*x#,##0.00"</code> 1631 formats 123 to 1632 <code>"$xx123.00"</code> 1633 , and 1234 to 1634 <code>"$1,234.00"</code> 1635 . 1636 </p> 1637 <ul> 1638 <li>When padding is in effect, the width of the positive 1639 subpattern, including prefix and suffix, determines the format 1640 width. For example, in the pattern <code>"* #0 1641 o''clock"</code>, the format width is 10. 1642 </li> 1643 <li>Some parameters which usually do not matter have meaning 1644 when padding is used, because the pattern width is significant with 1645 padding. In the pattern "* ##,##,#,##0.##", the format 1646 width is 14. The initial characters "##,##," do not affect 1647 the grouping size or maximum integer digits, but they do affect the 1648 format width.</li> 1649 <li>Padding may be inserted at one of four locations: before the 1650 prefix, after the prefix, before the suffix, or after the suffix. No 1651 padding can be specified in any other location. If there is no 1652 prefix, before the prefix and after the prefix are equivalent, 1653 likewise for the suffix.</li> 1654 <li>When specified in a pattern, the code point immediately 1655 following the pad escape is the pad character. This may be any 1656 character, including a special pattern character. That is, the pad 1657 escape <em>escapes</em> the following character. If there is no 1658 character after the pad escape, then the pattern is illegal. 1659 </li> 1660 </ul> 1661 <h3> 1662 3.7 <a name="Rounding" href="#Rounding">Rounding</a> 1663 </h3> 1664 <p>Patterns support rounding to a specific increment. For example, 1665 1230 rounded to the nearest 50 is 1250. Mathematically, rounding to 1666 specific increments is performed by dividing by the increment, 1667 rounding to an integer, then multiplying by the increment. To take a 1668 more bizarre example, 1.234 rounded to the nearest 0.65 is 1.3, as 1669 follows:</p> 1670 <table border="1" cellpadding="0" cellspacing="0" 1671 style="border-collapse: collapse"> 1672 <!-- nocaption --> 1673 <tr> 1674 <th>Original:</th> 1675 <td>1.234</td> 1676 </tr> 1677 <tr> 1678 <th>Divide by increment (0.65):</th> 1679 <td>1.89846…</td> 1680 </tr> 1681 <tr> 1682 <th>Round:</th> 1683 <td>2</td> 1684 </tr> 1685 <tr> 1686 <th>Multiply by increment (0.65):</th> 1687 <td>1.3</td> 1688 </tr> 1689 </table> 1690 <p>To specify a rounding increment in a pattern, include the 1691 increment in the pattern itself. "#,#50" specifies a 1692 rounding increment of 50. "#,##0.05" specifies a rounding 1693 increment of 0.05.</p> 1694 <ul> 1695 <li>Rounding only affects the string produced by formatting. It 1696 does not affect parsing or change any numerical values.</li> 1697 <li>An implementation may allow the specification of a <em>rounding 1698 mode</em> to determine how values are rounded. In the absence of such 1699 choices, the default is to round "half-even", as described 1700 in IEEE arithmetic. That is, it rounds towards the "nearest 1701 neighbor" unless both neighbors are equidistant, in which case, 1702 it rounds towards the even neighbor. Behaves as for round 1703 "half-up" if the digit to the left of the discarded 1704 fraction is odd; behaves as for round "half-down" if 1705 it's even. Note that this is the rounding mode that minimizes 1706 cumulative error when applied repeatedly over a sequence of 1707 calculations. 1708 </li> 1709 <li>Some locales use rounding in their currency formats to 1710 reflect the smallest currency denomination.</li> 1711 <li>In a pattern, digits '1' through '9' specify 1712 rounding, but otherwise behave identically to digit '0'.</li> 1713 </ul> 1714 <h3> 1715 3.8 <a name="Quoting_Rules" href="#Quoting_Rules">Quoting Rules</a> 1716 </h3> 1717 <blockquote> 1718 <p> 1719 Single quotes, (<b>'</b>), enclose bits of the pattern that 1720 should be treated literally. Inside a quoted string, two single 1721 quotes ('') are replaced with a single one ('). For 1722 example: 1723 <tt> 1724 <u>'X '</u>#<u>' Q '</u> 1725 </tt> 1726 -> <b>X 1939 Q </b>(Literal strings <u>underlined</u>.) 1727 </p> 1728 </blockquote> 1729 <h2> 1730 <a name="Currencies" href="#Currencies">4 Currencies</a> 1731 </h2> 1732 <p class="dtd"> 1733 <!ELEMENT currencies (alias | (default?, currency*, special*)) 1734 ><br> <!ELEMENT currency (alias | (((pattern+, 1735 displayName*, symbol*) | (displayName+, symbol*, pattern*) | 1736 (symbol+, pattern*))?, decimal*, group*, special*)) ><br> 1737 <!ELEMENT symbol ( #PCDATA ) ><br> <!ATTLIST symbol 1738 choice ( true | false ) #IMPLIED > <!-- deprecated --> 1739 </p> 1740 <blockquote> 1741 <p> 1742 <b>Note:</b> The term "pattern" appears twice in the 1743 above. The first is for consistency with all other cases of pattern 1744 + displayName; the second is for backwards compatibility. 1745 </p> 1746 </blockquote> 1747 <pre><currencies> 1748 <currency type="<span style="color: blue">USD</span>"> 1749 <displayName><span style="color: blue">Dollar</span></displayName> 1750 <symbol><span style="color: blue">$</span></symbol> 1751 </currency> 1752 <currency type ="<span style="color: blue">JPY</span>"> 1753 <displayName><span style="color: blue">Yen</span></displayName> 1754 <symbol><span style="color: blue">¥</span></symbol> 1755 </currency> 1756 <currency type="PTE"> 1757 <displayName><span style="color: blue">Escudo</span></displayName> 1758 <symbol><span style="color: blue">$</span></symbol> 1759 </currency> 1760</currencies></pre> 1761 <p>In formatting currencies, the currency number format is used 1762 with the appropriate symbol from <currencies>, according to the 1763 currency code. The <currencies> list can contain codes that are 1764 no longer in current use, such as PTE. The choice attribute has been 1765 deprecated.</p> 1766 <p>The count attribute distinguishes the different plural forms, 1767 such as in the following:</p> 1768 <pre><currencyFormats> 1769 <unitPattern count="other">{0} {1}</unitPattern> 1770 … 1771<currencies></pre> 1772 <pre><currency type="ZWD"> 1773 <displayName>Zimbabwe Dollar</displayName> 1774 <displayName count="one">Zimbabwe dollar</displayName> 1775 <displayName count="other">Zimbabwe dollars</displayName> 1776 <symbol>Z$</symbol> 1777</currency></pre> 1778 <p> 1779 To format a particular currency value "ZWD" for a 1780 particular numeric value <em>n</em> using the (long) display name: 1781 </p> 1782 <ol> 1783 <li>If the numeric value is exactly 0 or 1, first 1784 see if there is a count with a matching explicit 1785 number (0 or 1). If so, use that string (see 1786 <a href="#Explicit_0_1_rules">Explicit 0 and 1 rules</a>).</li> 1787 <li>Otherwise, determine the count value that corresponds to <em>n</em> 1788 using the rules in <i><a href="#Language_Plural_Rules">Section 1789 5 - Language Plural Rules</a></i></li> 1790 <li style="margin-top: 0.5em; margin-bottom: 0.5em">Next, get 1791 the currency unitPattern. 1792 <ol> 1793 <li>Look for a unitPattern element that matches the count 1794 value, starting in the current locale and then following the 1795 locale fallback chain up to, but not including root.</li> 1796 <li>If no matching unitPattern element was found in the 1797 previous step, then look for a unitPattern element that matches 1798 count="other", starting in the current locale and then 1799 following the locale fallback chain up to root (which has a 1800 unitPattern element with count="other" for every unit 1801 type).</li> 1802 <li>The resulting unitPattern element indicates the 1803 appropriate positioning of the numeric value and the currency 1804 display name.</li> 1805 </ol> 1806 </li> 1807 <li style="margin-top: 0.5em; margin-bottom: 0.5em">Next, get 1808 the displayName element for the currency. 1809 <ol> 1810 <li>Look for a displayName element that matches the count 1811 value, starting in the current locale and then following the 1812 locale fallback chain up to, but not including root.</li> 1813 <li>If no matching displayName element was found in the 1814 previous step, then look for a displayName element that matches 1815 count="other", starting in the current locale and then 1816 following the locale fallback chain up to, but not including root.</li> 1817 <li>If no matching displayName element was found in the 1818 previous step, then look for a displayName element that with no 1819 count, starting in the current locale and then following the 1820 locale fallback chain up to root.</li> 1821 <li>If there is no displayName element, use the currency code 1822 itself (for example, "ZWD").</li> 1823 </ol> 1824 </li> 1825 <li>Format the numeric value according to the locale. Use the 1826 locale’s <decimalFormats …> pattern, not the 1827 <currencyFormats> pattern that is used with the symbol (eg, 1828 Z$). As when formatting symbol currency values, reset the number of 1829 decimals according to the supplemental <currencyData> and use 1830 the currencyDecimal symbol if different from the decimal symbol. 1831 <ol> 1832 <li>The number of decimals should be overridable in an API, so 1833 that clients can choose between “2 US dollars” and “2.00 US 1834 dollars”.</li> 1835 </ol> 1836 </li> 1837 <li>Substitute the formatted numeric value for the {0} in the 1838 unitPattern, and the currency display name for the {1}.</li> 1839 </ol> 1840 <p>While for English this may seem overly complex, for some other 1841 languages different plural forms are used for different unit types; 1842 the plural forms for certain unit types may not use all of the 1843 plural-form tags defined for the language.</p> 1844 <p>For example, if the the currency is ZWD and the number is 1234, 1845 then the latter maps to count="other" for English. The unit 1846 pattern for that is "{0} {1}", and the display name is 1847 "Zimbabwe dollars". The final formatted number is then 1848 "1,234 Zimbabwe dollars".</p> 1849 <p>When the currency symbol is substituted into a pattern, there 1850 may be some further modifications, according to the following.</p> 1851 <pre><currencySpacing> 1852 <beforeCurrency> 1853 <currencyMatch>[:letter:]</currencyMatch> 1854 <surroundingMatch>[:digit:]</surroundingMatch> 1855 <insertBetween>&#x00a0;</insertBetween> 1856 </beforeCurrency> 1857 <afterCurrency> 1858 <currencyMatch>[:letter:]</currencyMatch> 1859 <surroundingMatch>[:digit:]</surroundingMatch> 1860 <insertBetween>&#x00a0;</insertBetween> 1861 </afterCurrency> 1862</currencySpacing> 1863</pre> 1864 <p> 1865 This element controls whether additional characters are inserted on 1866 the boundary between the symbol and the pattern. For example, with 1867 the above <i>currencySpacing</i>, inserting the symbol 1868 "US$" into the pattern "#,##0.00¤" would result 1869 in an extra <i>no-break space</i> inserted before the symbol, for 1870 example, "#,##0.00 US$". The <i>beforeCurrency</i> element 1871 governs this case, since we are looking <i>before</i> the 1872 "¤" symbol. The <i>currencyMatch</i> is positive, since the 1873 "U" in "US$" is at the start of the currency 1874 symbol being substituted. The <i>surroundingMatch</i> is positive, 1875 since the character just before the "¤" will be a digit. 1876 Because these two conditions are true, the insertion is made. 1877 </p> 1878 <p> 1879 Conversely, look at the pattern "¤#,##0.00" with the symbol 1880 "US$". In this case, there is no insertion; the result is 1881 simply "US$#,##0.00". The <i>afterCurrency</i> element 1882 governs this case, since we are looking <i>after</i> the 1883 "¤" symbol. The surroundingMatch is positive, since the 1884 character just after the "¤" will be a digit. However, the 1885 currencyMatch is <b>not</b> positive, since the "$" in 1886 "US$" is at the end of the currency symbol being 1887 substituted. So the insertion is not made. 1888 </p> 1889 <p> 1890 For more information on the matching used in the currencyMatch and 1891 surroundingMatch elements, see the main document <i><a 1892 href="tr35.html#Unicode_Sets">Appendix E: Unicode Sets</a></i>. 1893 </p> 1894 <p> 1895 Currencies can also contain optional grouping, decimal data, and 1896 pattern elements. This data is inherited from the <symbols> in 1897 the same locale data (if not present in the chain up to root), so 1898 only the <i>differing</i> data will be present. See the main document 1899 <i>Section 4.1 <a href="tr35.html#Multiple_Inheritance">Multiple 1900 Inheritance</a></i>. 1901 </p> 1902 <blockquote> 1903 <p class="note"> 1904 <b>Note: </b><i>Currency values should <b>never</b> be 1905 interchanged without a known currency code. You never want the 1906 number 3.5 interpreted as $3.50 by one user and €3.50 by another. 1907 </i>Locale data contains localization information for currencies, not a 1908 currency value for a country. A currency amount logically consists 1909 of a numeric value, plus an accompanying currency code (or 1910 equivalent). The currency code may be implicit in a protocol, such 1911 as where USD is implicit. But if the raw numeric value is 1912 transmitted without any context, then it has no definitive 1913 interpretation. 1914 </p> 1915 </blockquote> 1916 <p class="note">Notice that the currency code is completely 1917 independent of the end-user's language or locale. For example, 1918 BGN is the code for Bulgarian Lev. A currency amount of <BGN, 1919 1.23456×10³> would be localized for a Bulgarian user into "1 1920 234,56 лв." (using Cyrillic letters). For an English user it 1921 would be localized into the string "BGN 1,234.56" The 1922 end-user's language is needed for doing this last localization 1923 step; but that language is completely orthogonal to the currency code 1924 needed in the data. After all, the same English user could be working 1925 with dozens of currencies. Notice also that the currency code is also 1926 independent of whether currency values are inter-converted, which 1927 requires more interesting financial processing: the rate of 1928 conversion may depend on a variety of factors.</p> 1929 <p class="note">Thus logically speaking, once a currency amount is 1930 entered into a system, it should be logically accompanied by a 1931 currency code in all processing. This currency code is independent of 1932 whatever the user's original locale was. Only in badly-designed 1933 software is the currency code (or equivalent) not present, so that 1934 the software has to "guess" at the currency code based on 1935 the user's locale.</p> 1936 <blockquote> 1937 <p class="note"> 1938 <b>Note: </b>The number of decimal places <b>and</b> the rounding 1939 for each currency is not locale-specific data, and is not contained 1940 in the Locale Data Markup Language format. Those values override 1941 whatever is given in the currency numberFormat. For more 1942 information, see <i> <a href="#Supplemental_Currency_Data">Supplemental 1943 Currency Data</a></i>. 1944 </p> 1945 </blockquote> 1946 <p> 1947 For background information on currency names, see [<a 1948 href="tr35.html#CurrencyInfo">CurrencyInfo</a>]. 1949 </p> 1950 1951 <h3> 1952 4.1 <a name="Supplemental_Currency_Data" 1953 href="#Supplemental_Currency_Data">Supplemental Currency Data</a> 1954 </h3> 1955 <p class="dtd"> 1956 <!ELEMENT currencyData ( fractions*, region+ ) ><br> 1957 <!ELEMENT fractions ( info+ ) ><br> <br> <!ELEMENT 1958 info EMPTY ><br> <!ATTLIST info iso4217 NMTOKEN #REQUIRED 1959 ><br> <!ATTLIST info digits NMTOKEN #IMPLIED ><br> 1960 <!ATTLIST info rounding NMTOKEN #IMPLIED ><br> 1961 <!ATTLIST info cashDigits NMTOKEN #IMPLIED ><br> 1962 <!ATTLIST info cashRounding NMTOKEN #IMPLIED ><br> <br> 1963 <!ELEMENT region ( currency* ) ><br> <!ATTLIST region 1964 iso3166 NMTOKEN #REQUIRED ><br> <br> <!ELEMENT 1965 currency ( alternate* ) ><br> <!ATTLIST currency from 1966 NMTOKEN #IMPLIED ><br> <!ATTLIST currency to NMTOKEN 1967 #IMPLIED ><br> <!ATTLIST currency iso4217 NMTOKEN 1968 #REQUIRED ><br> <!ATTLIST currency tender ( true | false ) 1969 #IMPLIED > 1970 </p> 1971 <p>Each currencyData element contains one fractions element 1972 followed by one or more region elements. Here is an example for 1973 illustration.</p> 1974 <pre><supplementalData> 1975 <currencyData> 1976 <fractions> 1977 … 1978 <info iso4217="CHF" digits="2" rounding="5"/> 1979 … 1980 <info iso4217="<span style="color: blue">ITL</span>" digits="<span 1981 style="color: blue">0</span>"/> 1982 … 1983 </fractions> 1984 … 1985 <region iso3166="IT"> 1986 <currency iso4217="EUR" from="1999-01-01"/> 1987 <currency iso4217="ITL" from="1862-8-24" to="2002-02-28"/> 1988 </region> 1989 … 1990 <region iso3166="CS"> 1991 <currency iso4217="EUR" from="2003-02-04"/> 1992 <currency iso4217="CSD" from="2002-05-15"/> 1993 <currency iso4217="YUM" from="1994-01-24" to="2002-05-15"/> 1994 </region> 1995 … 1996 </currencyData> 1997… 1998</supplementalData></pre> 1999 <p>The fractions element contains any number of info elements, 2000 with the following attributes:</p> 2001 <ul> 2002 <li><b>iso4217: </b>the ISO 4217 code for the currency in 2003 question. If a particular currency does not occur in the fractions 2004 list, then it is given the defaults listed for the next two 2005 attributes.</li> 2006 <li><b>digits: </b>the minimum and maximum number of decimal 2007 digits normally formatted. The default is 2. For example, in the 2008 en_US locale with the default value of 2 digits, the value 1 USD 2009 would format as "$1.00", and the value 1.123 USD would format as → 2010 "$1.12".</li> 2011 <li><b>rounding: </b>the rounding increment, in units of 10<sup>-digits</sup>. 2012 The default is 0, which means no rounding is to be done. Therefore, 2013 rounding=0 and rounding=1 have identical behavior. Thus with 2014 fraction digits of 2 and rounding increment of 5, numeric values are 2015 rounded to the nearest 0.05 units in formatting. With fraction 2016 digits of 0 and rounding increment of 50, numeric values are rounded 2017 to the nearest 50.</li> 2018 <li><b>cashDigits: </b>the number of decimal digits to be used 2019 when formatting quantities used in cash transactions (as opposed to 2020 a quantity that would appear in a more formal setting, such as on a 2021 bank statement). If absent, the value of "digits" should be used as 2022 a default.</li> 2023 <li><b>cashRounding: </b>the cash rounding increment, in units 2024 of 10<sup>-cashDigits</sup>. The default is 0, which means no 2025 rounding is to be done; and as with rounding, this has the same 2026 effect as cashRounding="1". This is the rounding increment to be 2027 used when formatting quantities used in cash transactions (as 2028 opposed to a quantity that would appear in a more formal setting, 2029 such as on a bank statement). If absent, the value of "rounding" 2030 should be used as a default.</li> 2031 </ul> 2032 <p>For example, the following line</p> 2033 <pre> <info iso4217="CZK" digits="2" rounding="0"/></pre> 2034 <p>should cause the value 2.006 to be displayed as “2.01”, not 2035 “2.00”.</p> 2036 <p>Each region element contains one attribute:</p> 2037 <ul> 2038 <li><b>iso3166:</b> the ISO 3166 code for the region in 2039 question. The special value <i>XXX</i> can be used to indicate that 2040 the region has no valid currency or that the circumstances are 2041 unknown (usually used in conjunction with <i>before</i>, as 2042 described below).</li> 2043 </ul> 2044 <p>And can have any number of currency elements, with the ordered 2045 subelements.</p> 2046 <pre> <region iso3166="IT"> <!-- Italy --> 2047 <currency iso4217="EUR" from="2002-01-01"/> 2048 <currency iso4217="ITL" to="2001-12-31"/> 2049 </region></pre> 2050 <ul> 2051 <li><b>iso4217: </b>the ISO 4217 code for the currency in 2052 question. Note that some additional codes that were in widespread 2053 usage are included, others such as GHP are not included because they 2054 were never used.</li> 2055 <li><b>from: </b>the currency was valid from to the datetime 2056 indicated by the value. See the main document <i>Section 5.2.1 <a 2057 href="tr35.html#Date_Ranges">Dates and Date Ranges</a> 2058 </i>.</li> 2059 <li><b>to: </b>the currency was valid up to the datetime 2060 indicated by the value of <i>before</i>. See the main document <i>Section 2061 5.2.1 <a href="tr35.html#Date_Ranges">Dates and Date Ranges</a> 2062 </i>.</li> 2063 <li> 2064 <p> 2065 <b>tender: </b>indicates whether or not the ISO currency code 2066 represents a currency that was or is legal tender in some country. 2067 The default is "true". Certain ISO codes represent things 2068 like financial instruments or precious metals, and do not represent 2069 normally interchanged currencies. 2070 </p> 2071 </li> 2072 </ul> 2073 <p> 2074 That is, each currency element will list an interval in which it was 2075 valid. The <i>ordering</i> of the elements in the list tells us which 2076 was the primary currency during any period in time. Here is an 2077 example of such an overlap: 2078 </p> 2079 <pre><currency iso4217="CSD" to="2002-05-15"/> 2080<currency iso4217="YUD" from="1994-01-24" to="2002-05-15"/> 2081<currency iso4217="YUN" from="1994-01-01" to="1994-07-22"/></pre> 2082 <p> 2083 The <i>from</i> element is limited by the fact that ISO 4217 does not 2084 go very far back in time, so there may be no ISO code for the 2085 previous currency. 2086 </p> 2087 <p>Currencies change relatively frequently. There are different 2088 types of changes:</p> 2089 <ol> 2090 <li>YU=>CS (name change)</li> 2091 <li>CS=>RS+ME (split, different names)</li> 2092 <li>SD=>SD+SS (split, same name for one // South Sudan splits 2093 from Sudan)</li> 2094 <li>DE+DD=>DE (Union, reuses one name // East Germany unifies 2095 with Germany)</li> 2096 </ol> 2097 <p> 2098 The <a 2099 href="http://unstats.un.org/unsd/methods/m49/m49chang.htm#ftnq">UN 2100 Information</a> is used to determine dates due to country changes. 2101 </p> 2102 <p>When a code is no longer in use, it is terminated (see #1, #2, 2103 #4, #5)</p> 2104 <blockquote> 2105 <p>Example:</p> 2106 <ul> 2107 <li><currency iso4217="EUR" 2108 from="2003-02-04" to="2006-06-03"/></li> 2109 </ul> 2110 </blockquote> 2111 <p>When codes split, each of the new codes inherits (see #2, #3) 2112 the previous data. However, some modifications can be made if it is 2113 clear that currencies were only in use in one of the parts.</p> 2114 <p>When codes merge, the data is copied from the most populous 2115 part.</p> 2116 <blockquote> 2117 <p>Example. When CS split into RS and ME:</p> 2118 <ul> 2119 <li>RS & ME copy the former CS, except that the line for 2120 EUR is dropped from RS</li> 2121 <li>CS now terminates on Jun 3, 2006 (following the UN info)</li> 2122 </ul> 2123 </blockquote> 2124 <h2> 2125 <a name="Language_Plural_Rules" href="#Language_Plural_Rules">5 2126 Language Plural Rules</a> 2127 </h2> 2128 <p class="dtd"> 2129 <!ELEMENT plurals (pluralRules*, pluralRanges*) ><br> 2130 <!ATTLIST plurals type ( ordinal | cardinal ) #IMPLIED > 2131 <!-- default is cardinal --><br> <br> <!ELEMENT 2132 pluralRules (pluralRule*) ><br> <!ATTLIST pluralRules 2133 locales NMTOKENS #REQUIRED ><br> <br> <!ELEMENT 2134 pluralRule ( #PCDATA ) ><br> <!ATTLIST pluralRule count 2135 (zero | one | two | few | many | other) #REQUIRED > 2136 </p> 2137 <p>The plural categories are used to format messages with numeric 2138 placeholders, expressed as decimal numbers. The fundamental rule for 2139 determining plural categories is the existence of minimal pairs: 2140 whenever two different numbers may require different versions of the 2141 same message, then the numbers have different plural categories.</p> 2142 <p>This happens even if nouns are invariant; even if all English 2143 nouns were invariant (like “sheep”), English would still 2144 require 2 plural categories because of subject-verb agreement, and 2145 pronoun agreement. For example:</p> 2146 <ol> 2147 <li>1 sheep <strong>is</strong> here. Do you want to buy <strong>it</strong>? 2148 </li> 2149 <li>2 sheep <strong>are</strong> here. Do you want to buy <strong>them</strong>? 2150 </li> 2151 </ol> 2152 <p> 2153 For more information, see <a 2154 href="http://cldr.unicode.org/index/cldr-spec/plural-rules#TOC-Determining-Plural-Categories">Determining-Plural-Categories</a>. 2155 </p> 2156 <p>English does not have a separate plural category for 2157 “zero”, because it does not require a different message 2158 for “0”. For example, the same message can be used below, 2159 with just the numeric placeholder changing.</p> 2160 <ol> 2161 <li> 2162 <p>You have 3 friends online.</p> 2163 </li> 2164 <li> 2165 <p>You have 0 friends online.</p> 2166 </li> 2167 </ol> 2168 <p>However, across many languages it is commonly more natural to 2169 express "0" messages with a negative (“None of your 2170 friends are online.”) and "1" messages also with an 2171 alternate form “You have a friend online.”. Thus 2172 pluralized message APIs should also offer the ability to specify at 2173 least the 0 and 1 cases explicitly; developers can use that ability 2174 whenever these values might occur in a placeholder.</p> 2175 2176 <p>The 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".</p> 2177 <p>For example, in changing from 3 to 8:</p> 2178 <ul> 2179 <li>"a 3rd of a loaf" should result in "an 8th of a loaf", not "a 8th of a loaf"</li> 2180 <li>"a 3 foot stick" should result in "an 8 foot stick", not "a 8 foot stick"</li> 2181 </ul> 2182 <p>So 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.</p> 2183 <p>On 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.</p> 2184 <p>This section defines the types of plural forms that exist in a 2185 language—namely, the cardinal and ordinal plural forms. Cardinal 2186 plural forms express units such as time, currency or distance, used 2187 in conjunction with a number expressed in decimal digits (i.e. 2188 "2", not "two", and not an indefinite number such 2189 as "some" or "many"). Ordinal plural forms denote 2190 the order of items in a set and are always integers. For example, 2191 English has two forms for cardinals:</p> 2192 <ul> 2193 <li>form "one": 1 day</li> 2194 <li>form "other": 0 days, 2 days, 10 days, 0.3 days</li> 2195 </ul> 2196 <p>and four forms for ordinals:</p> 2197 <ul> 2198 <li>form "one": 1st floor, 21st floor, 101st floor</li> 2199 <li>form "two": 2nd floor, 22nd floor, 102nd floor</li> 2200 <li>form "few": 3rd floor, 23rd floor, 103rd floor</li> 2201 <li>form "other": 4th floor, 11th floor, 96th floor</li> 2202 </ul> 2203 <p>Other languages may have additional forms or only one form for 2204 each type of plural. CLDR provides the following tags for designating 2205 the various plural forms of a language; for a given language, only 2206 the tags necessary for that language are defined, along with the 2207 specific numeric ranges covered by each tag (for example, the plural 2208 form "few" may be used for the numeric range 2–4 in one 2209 language and 3–9 in another):</p> 2210 <ul> 2211 <li>zero (see also plural case “0”, described in 2212 <a href="#Explicit_0_1_rules">Explicit 0 and 1 rules</a>)</li> 2213 <li>one (see also plural case “1”, described in 2214 <a href="#Explicit_0_1_rules">Explicit 0 and 1 rules</a>)</li> 2215 <li>two</li> 2216 <li>few</li> 2217 <li>many</li> 2218 2219 2220 2221 </ul> 2222 <p>In addition, an "other" tag is always implicitly 2223 defined to cover the forms not explicitly designated by the tags 2224 defined for a language. This "other" tag is also used for 2225 languages that only have a single form (in which case no plural-form 2226 tags are explicitly defined for the language). For a more complex 2227 example, consider the cardinal rules for Russian and certain other 2228 languages:</p> 2229 <pre><pluralRules locales="hr ru sr uk"> 2230 <pluralRules count="one"><span style="color: blue">n mod 10 is 1 and n mod 100 is not 11</span></pluralRule> 2231 <pluralRules count="few"><span style="color: blue">n mod 10 in 2..4 and n mod 100 not in 12..14</span></pluralRule> 2232</pluralRules></pre> 2233 <p>These rules specify that Russian has a "one" form 2234 (for 1, 21, 31, 41, 51, …), a "few" form (for 2–4, 22–24, 2235 32–34, …), and implicitly an "other" form (for everything 2236 else: 0, 5–20, 25–30, 35–40, …, decimals). Russian does not need 2237 additional separate forms for zero, two, or many, so these are not 2238 defined.</p> 2239 <p>The plural category for negative numbers is 2240 calculated according to the absolute value of the source. (This may 2241 change in the future, if we find languages that have different 2242 behavior.)</p> 2243 <p> 2244 Plural categories may also differ according to the visible decimals. For example, here are some 2245 of the behaviors exhibited by different languages: 2246 </p> 2247 <div dir="ltr"> 2248 <table> 2249 <!-- nocaption --> 2250 <tr> 2251 <th>Behavior</th> 2252 <th>Description</th> 2253 <th>Example</th> 2254 </tr> 2255 <tr> 2256 <td>Base</td> 2257 <td>The fractions are ignored; the category is the same as the 2258 category of the integer.</td> 2259 <td>1.13 has the same plural category as 1.</td> 2260 </tr> 2261 <tr> 2262 <td>Separate</td> 2263 <td>All fractions by value are in one category (typically 2264 ‘other’ = ‘plural’).</td> 2265 <td>1.01 gets the same class as 9;<br>1.00 gets the same 2266 category as 1. 2267 </td> 2268 </tr> 2269 <tr> 2270 <td>Visible</td> 2271 <td>All visible fractions are in one category (typically 2272 ‘other’ = ‘plural).</td> 2273 <td>1.00, 1.01, 3.5 all get the same category.</td> 2274 </tr> 2275 <tr> 2276 <td>Digits</td> 2277 <td>The visible fraction determines the category.</td> 2278 <td>1.13 gets the same class as 13.</td> 2279 </tr> 2280 </table> 2281 </div> 2282 <br> 2283 <p>There are also variants of the above: for example, short 2284 fractions may have the Digits behavior, but longer fractions may just 2285 look at the final digit of the fraction.</p> 2286 2287 <h4> 2288 <a name="Explicit_0_1_rules" href="#Explicit_0_1_rules">Explicit 0 and 1 rules</a> 2289 </h4> 2290 <p > 2291 Some types of CLDR data (such as 2292 <a href="tr35-general.html#Unit_Elements">unitPatterns</a> and 2293 <a href="#Currencies">currency displayNames</a>) allow specification of plural 2294 rules for explicit cases “0” and “1”, in addition to the language-specific 2295 plural cases specified above: “zero”, “one”, “two” ... “other”. For the 2296 language-specific plural rules:</p> 2297 <ul> 2298 <li>The rules depend on language; for a given language, only a subset of the 2299 cases may be defined. For example, English only defines “one” and “other”, 2300 cases like “two” and “few” cannot be used in plurals for English CLDR 2301 items.</li> 2302 <li>Each plural case may cover multiple numeric values, and may depend on the 2303 formatting of those values. For example, in French the “one” case covers 2304 0.0 through 1.99.</li> 2305 <li>The “one” case, if defined, includes at least some formatted forms of the 2306 numeric value 1; the “zero” case, if defined, includes at least some 2307 formatted forms of the numeric value 0.</li> 2308 </ul> 2309 <p>By contrast, for the explicit cases “0” and “1”:</p> 2310 <ul> 2311 <li>The explicit “0” and “1” cases are not defined by language-specific rules, 2312 and are available in any language for the CLDR data items that accept them.</li> 2313 <li>The explicit “0” and “1” cases apply to the exact numeric values 0 and 1 2314 respectively. These cases are typically used for plurals of items that 2315 do not have fractional value, like books or files.</li> 2316 <li>The explicit “0” and “1” cases have precedence over the “zero” and “one” 2317 cases. For example, if for a particular element CLDR data includes values 2318 for both the “1” and “one” cases, then the “1” value is used for numeric 2319 values of exactly 1, while the “one” value is used for any other formatted 2320 numeric values matching the “one” plural rule for the language.</li> 2321 </ul> 2322 <p>Usage example: In English (which only defines language-specific 2323 rules for “one” and “other”) this can be used to have special behavior for 0:</p> 2324 <ul> 2325 <li>count=“0”: no books</li> 2326 <li>count=“one”: {0} book, e.g. “1 book”</li> 2327 <li>count=“other”: {0} books, e.g. “3 books”</li> 2328 </ul> 2329 2330 <h3> 2331 5.1 <a name="Plural_rules_syntax" href="#Plural_rules_syntax">Plural 2332 rules syntax</a> 2333 </h3> 2334 <p> 2335 The xml value for each pluralRule is a <em>condition</em> with a 2336 boolean result that specifies whether that rule (i.e. that plural 2337 form) applies to a given numeric value <em>n</em>, where n can be 2338 expressed as a decimal fraction. Clients of CLDR may express all the 2339 rules for a locale using the following syntax: 2340 </p> 2341 <pre>rules = rule (';' rule)*<br>rule = keyword ':' condition samples<br> | 'other' ':' samples<br>keyword = [a-z]+<br>keyword = [a-z]+</pre> 2342 <p>In CLDR, the keyword is the attribute value of 'count'. Those 2343 values in CLDR are currently limited to just what is in the DTD, but 2344 clients may support other values.</p> 2345 <p>The conditions themselves have the following syntax.</p> 2346 <pre>condition = and_condition ('or' and_condition)* 2347samples = ('@integer' sampleList)?<br> ('@decimal' sampleList)? 2348and_condition = relation ('and' relation)*<br>relation = is_relation | in_relation | within_relation <br>is_relation = expr 'is' ('not')? value<br>in_relation = expr (('not')? 'in' | '=' | '!=') range_list<br>within_relation = expr ('not')? 'within' range_list<br>expr = operand (('mod' | '%') value)? 2349operand = 'n' | 'i' | 'f' | 't' | 'v' | 'w'<br>range_list = (range | value) (',' range_list)*<br>range = value'..'value 2350sampleList = sampleRange (',' sampleRange)* (',' ('…'|'...'))? 2351sampleRange = decimalValue ('~' decimalValue)? 2352value = digit+ 2353decimalValue = value ('.' value)?<br>digit = 0|1|2|3|4|5|6|7|8|9 2354 </pre> 2355 <ul> 2356 <li>Whitespace (defined as Unicode <a 2357 href="http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5Cp%7BPattern_White_Space%7D">Pattern_White_Space</a>) 2358 can occur between or around any of the above tokens, with the 2359 exception of the tokens in value, digit, and decimalValue. 2360 </li> 2361 <li>In the syntax, <strong>and</strong> binds more tightly than 2362 <strong>or</strong>. So <strong>X or Y and Z</strong> is interpreted 2363 as <strong>(X or (Y and Z))</strong>. 2364 </li> 2365 <li>Each plural rule must be written to be self-contained, and 2366 not depend on the ordering. Thus rules must be mutually exclusive; 2367 for a given numeric value, only one rule can apply (i.e., the 2368 condition can only be true for one of the pluralRule elements. Each 2369 keyword can have at most one condition. The 'other' keyword must 2370 have an empty condition: it is only present for samples.</li> 2371 <li>The samples should be included, since they are used by 2372 client software for samples and determining whether the keyword has 2373 finite values or not.</li> 2374 <li>The 'other' keyword must have no condition, and all other 2375 keywords must have a condition.</li> 2376 </ul> 2377 <h4> 2378 <a name="Operands" href="#Operands">5.1.1 Operands</a> 2379 </h4> 2380 <p>The operands have the following meaning:</p> 2381 <div dir="ltr"> 2382 <table> 2383 <caption> 2384 <a name="Plural_Operand_Meanings" href="#Plural_Operand_Meanings">Plural 2385 Operand Meanings</a> 2386 </caption> 2387 <tr> 2388 <th>Symbol</th> 2389 <th>Value</th> 2390 </tr> 2391 <tr> 2392 <td>n</td> 2393 <td>absolute value of the source number (integer and 2394 decimals).</td> 2395 </tr> 2396 <tr> 2397 <td>i</td> 2398 <td>integer digits of n.</td> 2399 </tr> 2400 <tr> 2401 <td>v</td> 2402 <td>number of visible fraction digits in n, <em>with</em> 2403 trailing zeros. 2404 </td> 2405 </tr> 2406 <tr> 2407 <td>w</td> 2408 <td>number of visible fraction digits in n, <em>without</em> 2409 trailing zeros. 2410 </td> 2411 </tr> 2412 <tr> 2413 <td>f</td> 2414 <td>visible fractional digits in n, <em>with</em> trailing 2415 zeros. 2416 </td> 2417 </tr> 2418 <tr> 2419 <td>t</td> 2420 <td>visible fractional digits in n, <em>without</em> trailing 2421 zeros. 2422 </td> 2423 </tr> 2424 </table> 2425 </div> 2426 <br> 2427 2428 <div dir="ltr"> 2429 <table> 2430 <caption> 2431 <a name="Plural_Operand_Examples" href="#Plural_Operand_Examples">Plural 2432 Operand Examples</a> 2433 </caption> 2434 <colgroup> 2435 <col width="10%"> 2436 <col width="10%"> 2437 <col width="10%"> 2438 <col width="10%"> 2439 <col width="10%"> 2440 <col width="10%"> 2441 </colgroup> 2442 <tr> 2443 <th><strong>n</strong></th> 2444 <th><div align="center">i</div></th> 2445 <th><div align="center">v</div></th> 2446 <th><div align="center">w</div></th> 2447 <th><div align="center">f</div></th> 2448 <th><div align="center">t</div></th> 2449 </tr> 2450 <tr> 2451 <td>1</td> 2452 <td><div align="right">1</div></td> 2453 <td><div align="right">0</div></td> 2454 <td><div align="right">0</div></td> 2455 <td><div align="right">0</div></td> 2456 <td><div align="right">0</div></td> 2457 </tr> 2458 <tr> 2459 <td>1.0</td> 2460 <td><div align="right">1</div></td> 2461 <td><div align="right">1</div></td> 2462 <td><div align="right">0</div></td> 2463 <td><div align="right">0</div></td> 2464 <td><div align="right">0</div></td> 2465 </tr> 2466 <tr> 2467 <td>1.00</td> 2468 <td><div align="right">1</div></td> 2469 <td><div align="right">2</div></td> 2470 <td><div align="right">0</div></td> 2471 <td><div align="right">0</div></td> 2472 <td><div align="right">0</div></td> 2473 </tr> 2474 <tr> 2475 <td>1.3</td> 2476 <td><div align="right">1</div></td> 2477 <td><div align="right">1</div></td> 2478 <td><div align="right">1</div></td> 2479 <td><div align="right">3</div></td> 2480 <td><div align="right">3</div></td> 2481 </tr> 2482 <tr> 2483 <td>1.30</td> 2484 <td><div align="right">1</div></td> 2485 <td><div align="right">2</div></td> 2486 <td><div align="right">1</div></td> 2487 <td><div align="right">30</div></td> 2488 <td><div align="right">3</div></td> 2489 </tr> 2490 <tr> 2491 <td>1.03</td> 2492 <td><div align="right">1</div></td> 2493 <td><div align="right">2</div></td> 2494 <td><div align="right">2</div></td> 2495 <td><div align="right">3</div></td> 2496 <td><div align="right">3</div></td> 2497 </tr> 2498 <tr> 2499 <td>1.230</td> 2500 <td><div align="right">1</div></td> 2501 <td><div align="right">3</div></td> 2502 <td><div align="right">2</div></td> 2503 <td><div align="right">230</div></td> 2504 <td><div align="right">23</div></td> 2505 </tr> 2506 </table> 2507 </div> 2508 <br> 2509 <h4> 2510 <a name="Relations" href="#Relations">5.1.2 Relations</a> 2511 </h4> 2512 <p> 2513 The positive relations are of the format <strong>x = y</strong> and <strong>x 2514 = y mod z</strong>. The <strong>y</strong> value can be a comma-separated 2515 list, such as <strong>n = 3, 5, 7..15</strong>, and is treated as if 2516 each relation were expanded into an OR statement. The range value <strong>a..b</strong> 2517 is equivalent to listing all the <em><strong>integers</strong></em> between <strong>a</strong> 2518 and <strong>b</strong>, inclusive. When <strong>!=</strong> is used, 2519 it means the entire relation is negated. 2520 </p> 2521 2522 <table class='simple'> 2523 <caption> 2524 <a name="Relations_Examples" href="#Relations_Examples">Relations 2525 Examples</a> 2526 </caption> 2527 <tr> 2528 <th>Expression</th> 2529 <th>Meaning</th> 2530 </tr> 2531 <tr> 2532 <td>x = 2..4, 15</td> 2533 <td>x = 2 OR x = 3 OR x = 4 OR x = 15</td> 2534 </tr> 2535 <tr> 2536 <td>x != 2..4, 15</td> 2537 <td>NOT (x = 2 OR x = 3 OR x = 4 OR x = 15)</td> 2538 </tr> 2539 </table> 2540 <br> 2541 <table class='simple'> 2542 <!-- nocaption --> 2543 <tr> 2544 <th>Expression</th> 2545 <th>Value</th> 2546 </tr> 2547 <tr> 2548 <td>3.5 = 2..4, 15</td> 2549 <td>false</td> 2550 </tr> 2551 <tr> 2552 <td nowrap>3.5 != 2..4, 15</td> 2553 <td>true</td> 2554 </tr> 2555 <tr> 2556 <td>3 = 2..4, 15</td> 2557 <td>true</td> 2558 </tr> 2559 2560 <tr> 2561 <td>3 != 2..4, 15</td> 2562 <td>false</td> 2563 </tr> 2564 </table> 2565 <blockquote> 2566 <p> 2567 The old keywords 'mod', 'in', 'is', and 'within' are present only 2568 for backwards compatibility. The preferred form is to use '%' for 2569 modulo, and '=' or '!=' for the relations, with the operand 'i' 2570 instead of within. (The difference between <strong>in</strong> and <strong>within</strong> 2571 is that <strong>in</strong> only includes integers in the specified 2572 range, while <strong>within </strong>includes all values.) 2573 </p> 2574 </blockquote> 2575 <p dir="ltr"> 2576 The modulus (% or<strong> mod</strong>) is a remainder operation as 2577 defined in Java; for example, where <strong>n</strong> = 4.3 the 2578 result of <strong>n mod 3</strong> is 1.3. 2579 </p> 2580 <p> 2581 The values of relations are defined according to the operand as 2582 follows. Importantly, the results may depend on the visible decimals in the source, including 2583 trailing zeros. 2584 </p> 2585 <ol> 2586 <li>Let the base value BV be computed from absolute value of the 2587 original source number according to the operand.</li> 2588 <li>Let R be false when the comparison contains 2589 ‘not’.</li> 2590 <li>Let R be !R if the comparison contains 2591 ‘within’ and the source number is not an integer.</li> 2592 <li>If there is a module value MV, let BV be BV - floor(BV/MV).</li> 2593 <li>Let CR be the list of comparison ranges, normalized that 2594 overlapping ranges are merged. Single values in the rule are 2595 represented by a range with identical <start<sub>i</sub>, end<sub>i</sub>> 2596 values. 2597 </li> 2598 <li>Iterate through CR: 2599 <ul> 2600 <li>if start<sub>i</sub> ≤ BV ≤ end<sub>i</sub> then return R. 2601 </li> 2602 </ul> 2603 </li> 2604 <li>Otherwise return !R.</li> 2605 </ol> 2606 <p></p> 2607 2608 <table border="1"> 2609 <caption> 2610 <a name="Plural_Rules_Examples" href="#Plural_Rules_Examples">Plural 2611 Rules Examples</a> 2612 </caption> 2613 <tr> 2614 <th>Rules</th> 2615 <th>Comments</th> 2616 </tr> 2617 <tr> 2618 <td nowrap>one: n = 1<br> few: n = 2..4 2619 </td> 2620 <td>This defines two rules, for 'one' and 'few'. The condition 2621 for 'one' is "n = 1" which means that the number must be 2622 equal to 1 for this condition to pass. The condition for 'few' is 2623 "n = 2..4" which means that the number must be between 2 2624 and 4 inclusive for this condition to pass. All other numbers are 2625 assigned the keyword 'other' by the default rule.</td> 2626 </tr> 2627 <tr> 2628 <td nowrap>zero: n = 0 or n != 1 and n mod 100 = 1..19<br> 2629 one: n = 1 2630 </td> 2631 <td>Each rule must not overlap with other rules. Also note that 2632 a modulus is applied to n in the last rule, thus its condition 2633 holds for 119, 219, 319…</td> 2634 </tr> 2635 <tr> 2636 <td nowrap>one: n = 1<br> few: n mod 10 = 2..4 and n mod 2637 100 != 12..14 2638 </td> 2639 <td>This illustrates conjunction and negation. The condition 2640 for 'few' has two parts, both of which must be met: "n mod 10 2641 = 2..4" and "n mod 100 != 12..14". The first part 2642 applies a modulus to n before the test as in the previous example. 2643 The second part applies a different modulus and also uses negation, 2644 thus it matches all numbers <em>not</em> in 12, 13, 14, 112, 113, 2645 114, 212, 213, 214… 2646 </td> 2647 </tr> 2648 </table> 2649 <h4> 2650 <a name="Samples" href="#Samples">5.1.3 Samples</a> 2651 </h4> 2652 <p>Samples are provided if sample indicator (@integer or @decimal) 2653 is present on any rule. (CLDR always provides samples.)</p> 2654 <p>Where samples are provided, the absence of one of the sample 2655 indicators indicates that no numeric values can satisify that rule. 2656 For example, the rule "i = 1 and v = 0" can only have 2657 integer samples, so @decimal must not occur.</p> 2658 <p> 2659 The sampleRanges have a special notation: <strong>start</strong>~<strong>end</strong>. 2660 The <strong>start</strong> and <strong>end</strong> values must have 2661 the same number of decimal digits. The range encompasses all and only 2662 values those value <strong>v</strong> where <strong>start ≤ 2663 v ≤ end</strong>, and where <strong>v</strong> has the same number of decimal 2664 places as <strong>start</strong> and <strong>end</strong>. 2665 </p> 2666 <p>Samples must indicate whether they are infinite or not. The '…' 2667 marker must be present if and only infinitely many values (integer or 2668 decimal) can satisfy the rule. If a set is not infinite, it must list 2669 all the possible values.</p> 2670 <table border="1"> 2671 <caption> 2672 <a name="Plural_Samples_Examples" href="#Plural_Samples_Examples">Plural 2673 Samples Examples</a> 2674 </caption> 2675 <tr> 2676 <th>Rules</th> 2677 <th>Comments</th> 2678 </tr> 2679 <tr> 2680 <td nowrap>@integer 1, 3~5</td> 2681 <td>1, 3, 4, 5.</td> 2682 </tr> 2683 <tr> 2684 <td nowrap>@integer 3~5, 103~105, …</td> 2685 <td>Infinite set: 3, 4, 5, 103, 104, 105, …</td> 2686 </tr> 2687 <tr> 2688 <td nowrap>@decimal 1.3~1.5, 1.03~1.05, …</td> 2689 <td>Infinite set: 1.3, 1.4, 1.5, 1.03, 1.04, 1.05, …</td> 2690 </tr> 2691 </table> 2692 <br> 2693 <p>In determining whether a set of samples is infinite, leading 2694 zero integer digits and trailing zero decimals are not significant. 2695 Thus "i = 1 and f = 0" is satisfied by 01, 1, 1.0, 1.00, 2696 1.000, etc. but is still considered finite.</p> 2697 <h4> 2698 <a name="Using_cardinals" href="#Using_cardinals">5.1.4 Using 2699 Cardinals</a> 2700 </h4> 2701 <p>Elements such as <currencyFormats>, <currency> and 2702 <unit> provide selection among subelements designating various 2703 localized cardinal plural forms by tagging each of the relevant 2704 subelements with a different count value, or with no count value in 2705 some cases. Note that the plural forms for a specific currencyFormat, 2706 unit type, or currency type may not use all of the different 2707 plural-form tags defined for the language. To format a currency or 2708 unit type for a particular numeric value, determine the count value 2709 according to the plural rules for the language, then select the 2710 appropriate display form for the currency format, currency type or 2711 unit type using the rules in those sections:</p> 2712 <ul> 2713 <li>2.3 <a href="#Number_Symbols">Number Symbols</a> (for 2714 currencyFormats elements) 2715 </li> 2716 <li>Section 4 <a href="#Currencies">Currencies</a> (for currency 2717 elements) 2718 </li> 2719 <li>The main document section 5.11 <a 2720 href="tr35.html#Unit_Elements">Unit Elements</a></li> 2721 </ul> 2722 <h3> 2723 5.2 <a name="Plural_Ranges" href="#Plural_Ranges">Plural Ranges</a> 2724 </h3> 2725 2726 <p class="dtd"> 2727 <!ELEMENT pluralRanges (pluralRange*) ><br> <!ATTLIST 2728 pluralRanges locales NMTOKENS #REQUIRED ><br> <br> 2729 <!ELEMENT pluralRange ( #PCDATA ) ><br> <!ATTLIST 2730 pluralRange start (zero|one|two|few|many|other) #IMPLIED ><br> 2731 <!ATTLIST pluralRange end (zero|one|two|few|many|other) #IMPLIED 2732 ><br> <!ATTLIST pluralRange result 2733 (zero|one|two|few|many|other) #REQUIRED > 2734 </p> 2735 2736 <p>Often ranges of numbers are presented to users, such as in 2737 “Length: 3.2–4.5 centimeters”. This means any length from 3.2 cm to 2738 4.5 cm, inclusive. However, different languages have different 2739 conventions for the pluralization given to a range: should it be “0–1 2740 centimeter” or “0–1 centimeters”? This becomes much more complicated 2741 for languages that have many different plural forms, such as Russian 2742 or Arabic.</p> 2743 <p> 2744 The <strong>pluralRanges</strong> element provides information 2745 allowing an implementation to derive the plural category of a range 2746 from the plural categories of the <em>start</em> and <em>end</em> 2747 values. If there is no value for a <em><start,end></em> pair, 2748 the default result is <em>end</em>. However, where that result has 2749 been verified for a given language, it is included in the CLDR data. 2750 </p> 2751 <p>The data has been gathered presuming that in any usage, the 2752 start value is strictly less than the end value, and that no values 2753 are negative. Results for any cases that do not meet these criteria 2754 are undefined.</p> 2755 <h2> 2756 6 <a name="Rule-Based_Number_Formatting" 2757 href="#Rule-Based_Number_Formatting">Rule-Based Number 2758 Formatting</a> 2759 </h2> 2760 <p class="dtd"> 2761 <!ELEMENT rbnf ( alias | rulesetGrouping*) ><br> <br> 2762 <!ELEMENT rulesetGrouping ( alias | ruleset*) ><br> 2763 <!ATTLIST rulesetGrouping type NMTOKEN #REQUIRED><br> <br> 2764 <!ELEMENT ruleset ( alias | rbnfrule*) ><br> <!ATTLIST 2765 ruleset type NMTOKEN #REQUIRED><br> <!ATTLIST ruleset 2766 access ( public | private ) #IMPLIED ><br> <br> 2767 <!ELEMENT rbnfrule ( #PCDATA ) ><br> <!ATTLIST rbnfrule 2768 value CDATA #REQUIRED ><br> <!ATTLIST rbnfrule radix CDATA 2769 #IMPLIED ><br> <!ATTLIST rbnfrule decexp CDATA #IMPLIED 2770 > 2771 </p> 2772 <p>The rule-based number format (RBNF) encapsulates a set of rules 2773 for mapping binary numbers to and from a readable representation. 2774 They are typically used for spelling out numbers, but can also be 2775 used for other number systems like roman numerals, Chinese numerals, 2776 or for ordinal numbers (1st, 2nd, 3rd,…).</p> 2777 <p>Where, however, the CLDR plurals or ordinals can be used, their 2778 usage is recommended in preference to the RBNF data. First, the RBNF 2779 data is not completely fleshed out over all languages that otherwise 2780 have modern coverage. Secondly, the alternate forms are neither 2781 complete, nor useful without additional information. For example, for 2782 German there is spellout-cardinal-masculine, and 2783 spellout-cardinal-feminine. But a complete solution would have all 2784 genders (masculine/feminine/neuter), all cases (nominative, 2785 accusative, dative, genitive), plus context (with strong or weak 2786 determiner or none). Moreover, even for the alternate forms that do 2787 exist, CLDR does not supply any data for when to use one vs another 2788 (eg, when to use spellout-cardinal-masculine vs 2789 spellout-cardinal-feminine). So these data are inappropriate for 2790 general purpose software.</p> 2791 <p> 2792 There are 4 common spellout rules. Some languages may provide more 2793 than these 4 types:<br> 2794 </p> 2795 <ul> 2796 <li><strong>numbering: </strong>This is the default used when 2797 there is no context for the number. For many languages, this may 2798 also be used for enumeration of objects, like used when pronouncing 2799 "table number one" and "table number two". It can also be used for 2800 pronouncing a math equation, like "2 - 3 = -1".</li> 2801 <li><strong>numbering-year: </strong>This is used for cases 2802 where years are pronounced or written a certain way. An example in 2803 English is the year 1999, which comes out as "nineteen ninety-nine" 2804 instead of the numbering value "one thousand nine hundred 2805 ninety-nine". The rules for this type have undefined behavior for 2806 non-integer numbers, and values less than 1.</li> 2807 <li><strong>cardinal: </strong>This is used when providing the 2808 quantity of the number of objects. For many languages, there may not 2809 be a default cardinal type. Many languages require the notion of the 2810 gender and other grammatical properties so that the number and the 2811 objects being referenced are in grammatical agreement. An example of 2812 its usage is "one e-mail", "two people" or "three kilometers". Some 2813 languages may not have dedicated words for 0 or negative numbers for 2814 cardinals. In those cases, the words from the numbering type can be 2815 reused.</li> 2816 <li><strong>ordinal: </strong>This is used when providing the 2817 order of the number of objects. For many languages, there may not be 2818 a default ordinal type. Many languages also require the notion of 2819 the gender for ordinal so that the ordinal number and the objects 2820 being referenced are in grammatical agreement. An example of its 2821 usage is "first place", "second e-mail" or "third house on the 2822 right". The rules for this type have undefined behavior for 2823 non-integer numbers, and values less than 1.</li> 2824 </ul> 2825 <p> 2826 In addition to the spellout rules, there are also a numbering system 2827 rules. Even though they may be derived from a specific culture, they 2828 are typically not translated and the rules are in <strong>root</strong>. 2829 An example of these rules are the Roman numerals where the value 8 2830 comes out as VIII.<br> 2831 </p> 2832 <p> 2833 With regards to the number range supported for all these number 2834 types, the largest possible number range tries to be supported, but 2835 some languages may not have words for large numbers. For example, the 2836 old Roman numbering system can't support the value 5000 and beyond. 2837 For those unsupported cases, the default number format from CLDR is 2838 used.<br> 2839 </p> 2840 <p> 2841 Any rules marked as <strong>private</strong> should never be 2842 referenced externally. Frequently they only support a subrange of 2843 numbers that are used in the public rules.<br> 2844 </p> 2845 <p> 2846 The syntax used in the CLDR representation of rules is intended to be 2847 simply a transcription of ICU based RBNF rules into an XML compatible 2848 syntax. The rules are fairly sophisticated; for details see <i>Rule-Based 2849 Number Formatter</i> [<a href="tr35.html#RBNF">RBNF</a>]. 2850 </p> 2851 <p class="dtd"><ruleSetGrouping></p> 2852 <p>Used to group rules into functional sets for use with ICU. 2853 Currently, the valid types of rule set groupings are 2854 "SpelloutRules", "OrdinalRules", and 2855 "NumberingSystemRules".</p> 2856 <p class="dtd"><ruleset></p> 2857 <p>This element denotes a specific rule set to the number 2858 formatter. The ruleset is assumed to be a public ruleset unless the 2859 attribute type="private" is specified.</p> 2860 <p class="dtd"><rule></p> 2861 <p>Contains the actual formatting rule for a particular number or 2862 sequence of numbers. The "value" attribute is used to 2863 indicate the starting number to which the rule applies. The actual 2864 text of the rule is identical to the ICU syntax, with the exception 2865 that Unicode left and right arrow characters are used to replace < 2866 and > in the rule text, since < and > are reserved 2867 characters in XML. The "radix" attribute is used to 2868 indicate an alternate radix to be used in calculating the prefix and 2869 postfix values for number formatting. Alternate radix values are 2870 typically used for formatting year numbers in formal documents, such 2871 as "nineteen hundred seventy-six" instead of "one 2872 thousand nine hundred seventy-six".</p> 2873 2874 <h2> 2875 <a name="Parsing_Numbers" href="#Parsing_Numbers">7 Parsing 2876 Numbers</a> 2877 </h2> 2878 <p>The following elements are relevant to determining the value of 2879 a parsed number:</p> 2880 <ul> 2881 <li>A possible prefix or suffix, indicating sign</li> 2882 <li>A possible currency symbol or code</li> 2883 <li>Decimal digits</li> 2884 <li>A possible decimal separator</li> 2885 <li>A possible exponent</li> 2886 <li>A possible percent or per mille character</li> 2887 </ul> 2888 <p>Other characters should either be ignored, or indicate the end 2889 of input, depending on the application. The key point is to 2890 disambiguate the sets of characters that might serve in more than one 2891 position, based on context. For example, a period might be either the 2892 decimal separator, or part of a currency symbol (for example, 2893 "NA f."). Similarly, an "E" could be an exponent 2894 indicator, or a currency symbol (the Swaziland Lilangeni uses 2895 "E" in the "en" locale). An apostrophe might be 2896 the decimal separator, or might be the grouping separator.</p> 2897 <p>Here is a set of heuristic rules that may be helpful:</p> 2898 <ul> 2899 <li>Any character with the decimal digit property is unambiguous 2900 and should be accepted. 2901 <p> 2902 <b>Note:</b> In some environments, applications may independently 2903 wish to restrict the decimal digit set to prevent security 2904 problems. See [<a href="http://www.unicode.org/reports/tr41/#UTR36">UTR36</a>]. 2905 </p> 2906 </li> 2907 <li>The exponent character can only be interpreted as such if it 2908 occurs after at least one digit, and if it is followed by at least 2909 one digit, with only an optional sign in between. A regular 2910 expression may be helpful here.</li> 2911 <li>For the sign, decimal separator, percent, and per mille, use 2912 a set of all possible characters that can serve those functions. For 2913 example, the decimal separator set could include all of [.,']. 2914 (The actual set of characters can be derived from the number symbols 2915 in the By-Type charts <a href="tr35.html#ByType">[ByType]</a>, which 2916 list all of the values in CLDR.) To disambiguate, the decimal 2917 separator for the locale must be removed from the "ignore" 2918 set, and the grouping separator for the locale must be removed from 2919 the decimal separator set. The same principle applies to all sets 2920 and symbols: any symbol must appear in at most one set. 2921 </li> 2922 <li>Since there are a wide variety of currency symbols and 2923 codes, this should be tried before the less ambiguous elements. It 2924 may be helpful to develop a set of characters that can appear in a 2925 symbol or code, based on the currency symbols in the locale.</li> 2926 <li>Otherwise, a character should be ignored unless it is in the 2927 "stop" set. This includes even characters that are 2928 meaningful for formatting, for example, the grouping separator.</li> 2929 <li>If more than one sign, currency symbol, exponent, or 2930 percent/per mille occurs in the input, the first found should be 2931 used.</li> 2932 <li>A currency symbol in the input should be interpreted as the 2933 longest match found in the set of possible currency symbols.</li> 2934 <li>Especially in cases of ambiguity, the user's input 2935 should be echoed back, properly formatted according to the locale, 2936 before it is actually used for anything.</li> 2937 </ul> 2938 2939 <hr> 2940 <p class="copyright"> 2941 Copyright © 2001–2018 Unicode, Inc. All 2942 Rights Reserved. The Unicode Consortium makes no expressed or implied 2943 warranty of any kind, and assumes no liability for errors or 2944 omissions. No liability is assumed for incidental and consequential 2945 damages in connection with or arising out of the use of the 2946 information or programs contained or accompanying this technical 2947 report. The Unicode <a href="http://unicode.org/copyright.html">Terms 2948 of Use</a> apply. 2949 </p> 2950 <p class="copyright">Unicode and the Unicode logo are trademarks 2951 of Unicode, Inc., and are registered in some jurisdictions.</p> 2952 2953 </div> 2954</body> 2955 2956</html> 2957