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