unumberoptions.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. // © 2017 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. #ifndef __UNUMBEROPTIONS_H__
  4. #define __UNUMBEROPTIONS_H__
  5. #include "unicode/utypes.h"
  6. #if !UCONFIG_NO_FORMATTING
  7. /**
  8. * \file
  9. * \brief C API: Header-only input options for various number formatting APIs.
  10. *
  11. * You do not normally need to include this header file directly, because it is included in all
  12. * files that use these enums.
  13. */
  14. /** The possible number format rounding modes.
  15. *
  16. * <p>
  17. * For more detail on rounding modes, see:
  18. * https://unicode-org.github.io/icu/userguide/format_parse/numbers/rounding-modes
  19. *
  20. * @stable ICU 2.0
  21. */
  22. typedef enum UNumberFormatRoundingMode {
  23. UNUM_ROUND_CEILING,
  24. UNUM_ROUND_FLOOR,
  25. UNUM_ROUND_DOWN,
  26. UNUM_ROUND_UP,
  27. /**
  28. * Half-even rounding
  29. * @stable, ICU 3.8
  30. */
  31. UNUM_ROUND_HALFEVEN,
  32. #ifndef U_HIDE_DEPRECATED_API
  33. /**
  34. * Half-even rounding, misspelled name
  35. * @deprecated, ICU 3.8
  36. */
  37. UNUM_FOUND_HALFEVEN = UNUM_ROUND_HALFEVEN,
  38. #endif /* U_HIDE_DEPRECATED_API */
  39. UNUM_ROUND_HALFDOWN = UNUM_ROUND_HALFEVEN + 1,
  40. UNUM_ROUND_HALFUP,
  41. /**
  42. * ROUND_UNNECESSARY reports an error if formatted result is not exact.
  43. * @stable ICU 4.8
  44. */
  45. UNUM_ROUND_UNNECESSARY,
  46. /**
  47. * Rounds ties toward the odd number.
  48. * @stable ICU 69
  49. */
  50. UNUM_ROUND_HALF_ODD,
  51. /**
  52. * Rounds ties toward +∞.
  53. * @stable ICU 69
  54. */
  55. UNUM_ROUND_HALF_CEILING,
  56. /**
  57. * Rounds ties toward -∞.
  58. * @stable ICU 69
  59. */
  60. UNUM_ROUND_HALF_FLOOR,
  61. } UNumberFormatRoundingMode;
  62. /**
  63. * An enum declaring the strategy for when and how to display grouping separators (i.e., the
  64. * separator, often a comma or period, after every 2-3 powers of ten). The choices are several
  65. * pre-built strategies for different use cases that employ locale data whenever possible. Example
  66. * outputs for 1234 and 1234567 in <em>en-IN</em>:
  67. *
  68. * <ul>
  69. * <li>OFF: 1234 and 12345
  70. * <li>MIN2: 1234 and 12,34,567
  71. * <li>AUTO: 1,234 and 12,34,567
  72. * <li>ON_ALIGNED: 1,234 and 12,34,567
  73. * <li>THOUSANDS: 1,234 and 1,234,567
  74. * </ul>
  75. *
  76. * <p>
  77. * The default is AUTO, which displays grouping separators unless the locale data says that grouping
  78. * is not customary. To force grouping for all numbers greater than 1000 consistently across locales,
  79. * use ON_ALIGNED. On the other hand, to display grouping less frequently than the default, use MIN2
  80. * or OFF. See the docs of each option for details.
  81. *
  82. * <p>
  83. * Note: This enum specifies the strategy for grouping sizes. To set which character to use as the
  84. * grouping separator, use the "symbols" setter.
  85. *
  86. * @stable ICU 63
  87. */
  88. typedef enum UNumberGroupingStrategy {
  89. /**
  90. * Do not display grouping separators in any locale.
  91. *
  92. * @stable ICU 61
  93. */
  94. UNUM_GROUPING_OFF,
  95. /**
  96. * Display grouping using locale defaults, except do not show grouping on values smaller than
  97. * 10000 (such that there is a <em>minimum of two digits</em> before the first separator).
  98. *
  99. * <p>
  100. * Note that locales may restrict grouping separators to be displayed only on 1 million or
  101. * greater (for example, ee and hu) or disable grouping altogether (for example, bg currency).
  102. *
  103. * <p>
  104. * Locale data is used to determine whether to separate larger numbers into groups of 2
  105. * (customary in South Asia) or groups of 3 (customary in Europe and the Americas).
  106. *
  107. * @stable ICU 61
  108. */
  109. UNUM_GROUPING_MIN2,
  110. /**
  111. * Display grouping using the default strategy for all locales. This is the default behavior.
  112. *
  113. * <p>
  114. * Note that locales may restrict grouping separators to be displayed only on 1 million or
  115. * greater (for example, ee and hu) or disable grouping altogether (for example, bg currency).
  116. *
  117. * <p>
  118. * Locale data is used to determine whether to separate larger numbers into groups of 2
  119. * (customary in South Asia) or groups of 3 (customary in Europe and the Americas).
  120. *
  121. * @stable ICU 61
  122. */
  123. UNUM_GROUPING_AUTO,
  124. /**
  125. * Always display the grouping separator on values of at least 1000.
  126. *
  127. * <p>
  128. * This option ignores the locale data that restricts or disables grouping, described in MIN2 and
  129. * AUTO. This option may be useful to normalize the alignment of numbers, such as in a
  130. * spreadsheet.
  131. *
  132. * <p>
  133. * Locale data is used to determine whether to separate larger numbers into groups of 2
  134. * (customary in South Asia) or groups of 3 (customary in Europe and the Americas).
  135. *
  136. * @stable ICU 61
  137. */
  138. UNUM_GROUPING_ON_ALIGNED,
  139. /**
  140. * Use the Western defaults: groups of 3 and enabled for all numbers 1000 or greater. Do not use
  141. * locale data for determining the grouping strategy.
  142. *
  143. * @stable ICU 61
  144. */
  145. UNUM_GROUPING_THOUSANDS
  146. #ifndef U_HIDE_INTERNAL_API
  147. ,
  148. /**
  149. * One more than the highest UNumberGroupingStrategy value.
  150. *
  151. * @internal ICU 62: The numeric value may change over time; see ICU ticket #12420.
  152. */
  153. UNUM_GROUPING_COUNT
  154. #endif /* U_HIDE_INTERNAL_API */
  155. } UNumberGroupingStrategy;
  156. #endif /* #if !UCONFIG_NO_FORMATTING */
  157. #endif //__UNUMBEROPTIONS_H__